diff --git a/chain/src/chain.rs b/chain/src/chain.rs index 04ee2d97..61aac87d 100644 --- a/chain/src/chain.rs +++ b/chain/src/chain.rs @@ -176,16 +176,13 @@ impl Chain { Err(e) => return Err(Error::StoreErr(e, "chain init load head".to_owned())), }; - // make sure sync_head is available for later use - let _ = match chain_store.get_sync_head() { - Ok(tip) => tip, - Err(NotFoundErr) => { - let tip = chain_store.head().unwrap(); - chain_store.save_sync_head(&tip)?; - tip - }, - Err(e) => return Err(Error::StoreErr(e, "chain init sync head".to_owned())), - }; + // Make sure we have a sync_head available for later use. + // We may have been tracking an invalid chain on a now banned peer + // so we want to reset the both sync_head and header_head on restart to handle this. + // TODO - handle sync_head/header_head and peer banning in a more effective way. + let tip = chain_store.head().unwrap(); + chain_store.save_header_head(&tip)?; + chain_store.save_sync_head(&tip)?; info!( LOGGER, diff --git a/grin/src/sync.rs b/grin/src/sync.rs index 4325317d..ec7c79a1 100644 --- a/grin/src/sync.rs +++ b/grin/src/sync.rs @@ -154,6 +154,7 @@ pub fn header_sync(peers: Peers, chain: Arc) { if let Some(peer) = peers.most_work_peer() { if let Ok(p) = peer.try_read() { let peer_difficulty = p.info.total_difficulty.clone(); + debug!(LOGGER, "sync: header_sync: {}, {}", difficulty, peer_difficulty); if peer_difficulty > difficulty { let _ = request_headers( peer.clone(),