Skip to content

Commit

Permalink
Retry get_block_hash as well as get_block (#820)
Browse files Browse the repository at this point in the history
  • Loading branch information
casey authored Nov 21, 2022
1 parent cf8684c commit 3916d4b
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/index/updater.rs
Original file line number Diff line number Diff line change
Expand Up @@ -150,13 +150,12 @@ impl Updater {
loop {
match client
.get_block_hash(height)
.into_option()?
.map(|hash| client.get_block(&hash))
.transpose()
.into_option()
.and_then(|option| option.map(|hash| Ok(client.get_block(&hash)?)).transpose())
{
Err(err) => {
if cfg!(test) {
return Err(err.into());
return Err(err);
}

errors += 1;
Expand All @@ -165,7 +164,7 @@ impl Updater {

if seconds > 120 {
log::error!("would sleep for more than 120s, giving up");
return Err(err.into());
return Err(err);
}

thread::sleep(Duration::from_secs(seconds));
Expand Down

0 comments on commit 3916d4b

Please sign in to comment.