From 882d1c1687800d6e1ff7f8f7827b165332352085 Mon Sep 17 00:00:00 2001 From: Dave Collins Date: Mon, 29 Jul 2013 16:58:48 -0500 Subject: [PATCH] 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. --- accept.go | 1 + 1 file changed, 1 insertion(+) diff --git a/accept.go b/accept.go index 58a7d150..7bad3454 100644 --- a/accept.go +++ b/accept.go @@ -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