Don't swallow errors in body_sync (#3300)

We handle them inside but it makes the code more cluttered
This commit is contained in:
hashmap 2020-04-18 14:51:18 +02:00 committed by GitHub
parent 4024ee3839
commit 0da88f7046
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 24 deletions

View file

@ -72,16 +72,10 @@ impl BodySync {
/// Return true if txhashset download is needed (when requested block is under the horizon).
fn body_sync(&mut self) -> Result<bool, chain::Error> {
let mut hashes: Option<Vec<Hash>> = Some(vec![]);
let txhashset_needed = match self
let txhashset_needed = self
.chain
.check_txhashset_needed("body_sync".to_owned(), &mut hashes)
{
Ok(v) => v,
Err(e) => {
error!("body_sync: failed to call txhashset_needed: {:?}", e);
return Ok(false);
}
};
.check_txhashset_needed("body_sync".to_owned(), &mut hashes)?;
if txhashset_needed {
debug!(
"body_sync: cannot sync full blocks earlier than horizon. will request txhashset",
@ -89,13 +83,9 @@ impl BodySync {
return Ok(true);
}
let mut hashes = match hashes {
Some(v) => v,
None => {
error!("unexpected: hashes is None");
return Ok(false);
}
};
let mut hashes = hashes.ok_or_else(|| {
chain::ErrorKind::SyncError("Got no hashes for body sync".to_string())
})?;
hashes.reverse();

View file

@ -202,14 +202,8 @@ impl SyncRunner {
continue;
}
let check_run = match body_sync.check_run(&head, highest_height) {
Ok(v) => v,
Err(e) => {
error!("check_run failed: {:?}", e);
continue;
}
};
let check_run =
unwrap_or_restart_loop!(body_sync.check_run(&head, highest_height));
if check_run {
check_state_sync = true;
}