diff --git a/servers/src/grin/sync/body_sync.rs b/servers/src/grin/sync/body_sync.rs index 6c436bba2..f2645d92d 100644 --- a/servers/src/grin/sync/body_sync.rs +++ b/servers/src/grin/sync/body_sync.rs @@ -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 { let mut hashes: Option> = 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(); diff --git a/servers/src/grin/sync/syncer.rs b/servers/src/grin/sync/syncer.rs index d6b98454e..b25494cd9 100644 --- a/servers/src/grin/sync/syncer.rs +++ b/servers/src/grin/sync/syncer.rs @@ -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; }