Update block manager chainstate for all sources.

This commit updates the block manager's local chain state when a block
processed by submitting it directly to the block manager as opposed to
only when it comes from the network.

Also, it modifies the submitblock RPC to use the concurrent safe block
manager process block instead of the unsafe btcchain version.

The combination of these two fixes ensure the internal block manager chain
state is properly synced with the actual btcchain state regardless of how
blocks are added.
This commit is contained in:
Dave Collins 2014-05-02 19:52:15 -05:00
parent 92ca0e92c0
commit 0a7543516c
2 changed files with 7 additions and 1 deletions

View file

@ -1028,6 +1028,12 @@ out:
}
}
// 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)
blockSha, _ := msg.block.Sha()
msg.reply <- processBlockResponse{
isOrphan: b.blockChain.IsKnownOrphan(

View file

@ -1870,7 +1870,7 @@ func handleSubmitBlock(s *rpcServer, cmd btcjson.Cmd) (interface{}, error) {
return nil, err
}
err = s.server.blockManager.blockChain.ProcessBlock(block, false)
_, err = s.server.blockManager.ProcessBlock(block)
if err != nil {
return fmt.Sprintf("rejected: %s", err.Error()), nil
}