Skip to content

Commit 7e6c853

Browse files
enha: make rpc-downloader shutdown faster (#1764)
1 parent be11f11 commit 7e6c853

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/bin/rpc_downloader.rs

+7-1
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,8 @@ async fn download(
131131
start: BlockNumber,
132132
end_inclusive: BlockNumber,
133133
) -> anyhow::Result<()> {
134+
const TASK_NAME: &str = "rpc-downloader::download";
135+
134136
// calculate current block
135137
let mut current = match rpc_storage.read_max_block_number_in_range(start, end_inclusive).await? {
136138
Some(number) => number.next_block_number(),
@@ -141,11 +143,15 @@ async fn download(
141143
// download blocks
142144
while current <= end_inclusive {
143145
loop {
146+
if GlobalState::is_shutdown_warn(TASK_NAME) {
147+
break;
148+
}
149+
144150
// retrieve block
145151
let block_json = match chain.fetch_block(current).await {
146152
Ok(json) => json,
147153
Err(e) => {
148-
tracing::warn!(reason = ?e, "retrying block download");
154+
tracing::warn!(reason = ?e, "failed to fetch, retrying block download");
149155
continue;
150156
}
151157
};

0 commit comments

Comments
 (0)