mirror of
https://github.com/mimblewimble/grin.git
synced 2025-01-21 03:21:08 +03:00
Don't swallow errors in body_sync (#3300)
We handle them inside but it makes the code more cluttered
This commit is contained in:
parent
4024ee3839
commit
0da88f7046
2 changed files with 8 additions and 24 deletions
|
@ -72,16 +72,10 @@ impl BodySync {
|
||||||
/// Return true if txhashset download is needed (when requested block is under the horizon).
|
/// Return true if txhashset download is needed (when requested block is under the horizon).
|
||||||
fn body_sync(&mut self) -> Result<bool, chain::Error> {
|
fn body_sync(&mut self) -> Result<bool, chain::Error> {
|
||||||
let mut hashes: Option<Vec<Hash>> = Some(vec![]);
|
let mut hashes: Option<Vec<Hash>> = Some(vec![]);
|
||||||
let txhashset_needed = match self
|
let txhashset_needed = self
|
||||||
.chain
|
.chain
|
||||||
.check_txhashset_needed("body_sync".to_owned(), &mut hashes)
|
.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);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
if txhashset_needed {
|
if txhashset_needed {
|
||||||
debug!(
|
debug!(
|
||||||
"body_sync: cannot sync full blocks earlier than horizon. will request txhashset",
|
"body_sync: cannot sync full blocks earlier than horizon. will request txhashset",
|
||||||
|
@ -89,13 +83,9 @@ impl BodySync {
|
||||||
return Ok(true);
|
return Ok(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut hashes = match hashes {
|
let mut hashes = hashes.ok_or_else(|| {
|
||||||
Some(v) => v,
|
chain::ErrorKind::SyncError("Got no hashes for body sync".to_string())
|
||||||
None => {
|
})?;
|
||||||
error!("unexpected: hashes is None");
|
|
||||||
return Ok(false);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
hashes.reverse();
|
hashes.reverse();
|
||||||
|
|
||||||
|
|
|
@ -202,14 +202,8 @@ impl SyncRunner {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
let check_run = match body_sync.check_run(&head, highest_height) {
|
let check_run =
|
||||||
Ok(v) => v,
|
unwrap_or_restart_loop!(body_sync.check_run(&head, highest_height));
|
||||||
Err(e) => {
|
|
||||||
error!("check_run failed: {:?}", e);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
if check_run {
|
if check_run {
|
||||||
check_state_sync = true;
|
check_state_sync = true;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue