Ensure height is set on block as well as the node.

Even though the code currently makes heavy use of nodes which will have
the appropriate height, blocks which did not come from the database will
not have a height set.  As a result, this could possibly result in a
height of 0 being used when unintended.  By setting the block height in
the block as soon as its known (regardless of the source), we can future
proof against bugs that would likely be hard to track down.
This commit is contained in:
Dave Collins 2013-07-29 16:58:48 -05:00
parent 6409879e14
commit 882d1c1687

View file

@ -28,6 +28,7 @@ func (b *BlockChain) maybeAcceptBlock(block *btcutil.Block) error {
if prevNode != nil {
blockHeight = prevNode.height + 1
}
block.SetHeight(blockHeight)
// Ensure the difficulty specified in the block header matches the
// calculated difficulty based on the previous block and difficulty