diff --git a/chain/src/pipe.rs b/chain/src/pipe.rs index 2cc4f2893..b34f681bb 100644 --- a/chain/src/pipe.rs +++ b/chain/src/pipe.rs @@ -322,22 +322,9 @@ fn update_head(b: &Block, ctx: &mut BlockContext) -> Result, Error> // update the block height index ctx.store.setup_height(&b.header).map_err(&Error::StoreErr)?; - // in sync mode, only update the "body chain", otherwise update both the - // "header chain" and "body chain" - if ctx.opts.intersects(SYNC) { - ctx.store.save_body_head(&tip).map_err(&Error::StoreErr)?; - } else { - ctx.store.save_head(&tip).map_err(&Error::StoreErr)?; - } - // TODO if we're switching branch, make sure to backtrack the sum trees - + ctx.store.save_head(&tip).map_err(&Error::StoreErr)?; ctx.head = tip.clone(); - info!( - LOGGER, - "Updated head to {} at {}.", - b.hash(), - b.header.height - ); + info!(LOGGER, "Updated head to {} at {}.", b.hash(), b.header.height); Ok(Some(tip)) } else { Ok(None) diff --git a/grin/src/adapters.rs b/grin/src/adapters.rs index e80a50e6d..a6eaff884 100644 --- a/grin/src/adapters.rs +++ b/grin/src/adapters.rs @@ -60,8 +60,9 @@ impl NetAdapter for NetToChainAdapter { let bhash = b.hash(); debug!( LOGGER, - "Received block {} from network, going to process.", - bhash + "Received block {} at {} from network, going to process.", + bhash, + b.header.height, ); // pushing the new block through the chain pipeline diff --git a/grin/src/sync.rs b/grin/src/sync.rs index b66662a33..85c5ceac6 100644 --- a/grin/src/sync.rs +++ b/grin/src/sync.rs @@ -126,6 +126,9 @@ impl Syncer { let mut prev_h = header_head.last_block_h; while prev_h != full_head.last_block_h { let header = self.chain.get_block_header(&prev_h)?; + if header.height < full_head.height { + break; + } blocks_to_download.push(header.hash()); prev_h = header.previous; }