Browse Source
Set CBlockIndex.hashAnchor correctly in ConnectBlock
pull/4/head
Jack Grigg
8 years ago
No known key found for this signature in database
GPG Key ID: 6A6914DAFBEA00DA
1 changed files with
8 additions and
2 deletions
-
src/main.cpp
|
|
@ -2033,8 +2033,12 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin |
|
|
|
// Special case for the genesis block, skipping connection of its transactions
|
|
|
|
// (its coinbase is unspendable)
|
|
|
|
if (block.GetHash() == chainparams.GetConsensus().hashGenesisBlock) { |
|
|
|
if (!fJustCheck) |
|
|
|
if (!fJustCheck) { |
|
|
|
view.SetBestBlock(pindex->GetBlockHash()); |
|
|
|
// Before the genesis block, there was an empty tree
|
|
|
|
ZCIncrementalMerkleTree tree; |
|
|
|
pindex->hashAnchor = tree.root(); |
|
|
|
} |
|
|
|
return true; |
|
|
|
} |
|
|
|
|
|
|
@ -2080,7 +2084,9 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin |
|
|
|
// block position,
|
|
|
|
auto old_tree_root = view.GetBestAnchor(); |
|
|
|
// saving the top anchor in the block index as we go.
|
|
|
|
pindex->hashAnchor = old_tree_root; |
|
|
|
if (!fJustCheck) { |
|
|
|
pindex->hashAnchor = old_tree_root; |
|
|
|
} |
|
|
|
ZCIncrementalMerkleTree tree; |
|
|
|
// This should never fail: we should always be able to get the root
|
|
|
|
// that is on the tip of our chain
|
|
|
|