Update chain state with best block.

Rather than updating the new chain state with the hash and height of the
block that was just processed, query the database for the best block.
This is needed because the block that was just processed might be a side
chain block or have caused a reorg.
This commit is contained in:
Dave Collins 2014-03-20 14:08:46 -05:00
parent 1d674905e0
commit f1a4dfb86d

View file

@ -548,7 +548,12 @@ func (b *blockManager) handleBlockMsg(bmsg *blockMsg) {
if !b.blockChain.IsKnownOrphan(blockSha) {
delete(b.blockPeer, *blockSha)
b.logBlockHeight(bmsg.block)
b.updateChainState(blockSha, bmsg.block.Height())
// Query the db for the latest best block since the block
// that was processed could be on a side chain or have caused
// a reorg.
newestSha, newestHeight, _ := b.server.db.NewestSha()
b.updateChainState(newestSha, newestHeight)
}
// Sync the db to disk.