aboutsummaryrefslogtreecommitdiff
path: root/src/test/util
diff options
context:
space:
mode:
authorCarl Dong <contact@carldong.me>2021-04-23 15:24:47 -0400
committerCarl Dong <contact@carldong.me>2021-05-27 13:50:11 -0400
commite6b4aa6eb53dc555ecab2922af35e7a2572faf4f (patch)
tree42927d85d5a098a2a333d32cbcc0333eaba78283 /src/test/util
parent9ecade14252ad1972f668d2d2e4ef44fdfcb944a (diff)
downloadbitcoin-e6b4aa6eb53dc555ecab2922af35e7a2572faf4f.tar.xz
miner: Pass in chainman to RegenerateCommitments
Pass in chainman instead of prev_block so that we can enforce the block.hashPrevBlock refers to prev_block invariant in the function itself. We should probably rethink BlockAssembler's API and somehow include commitment regeneration functionality in there. Something like a variant of CreateNewBlock that takes in a std::vector<TxRef> and return a CBlock instead of CBlockTemplate. That could avoid reaching for LookupBlockIndex at all.
Diffstat (limited to 'src/test/util')
-rw-r--r--src/test/util/setup_common.cpp3
1 files changed, 1 insertions, 2 deletions
diff --git a/src/test/util/setup_common.cpp b/src/test/util/setup_common.cpp
index f92e4c4b99..f53c505e7c 100644
--- a/src/test/util/setup_common.cpp
+++ b/src/test/util/setup_common.cpp
@@ -246,8 +246,7 @@ CBlock TestChain100Setup::CreateAndProcessBlock(const std::vector<CMutableTransa
for (const CMutableTransaction& tx : txns) {
block.vtx.push_back(MakeTransactionRef(tx));
}
- CBlockIndex* prev_block = WITH_LOCK(::cs_main, return g_chainman.m_blockman.LookupBlockIndex(block.hashPrevBlock));
- RegenerateCommitments(block, prev_block);
+ RegenerateCommitments(block, *Assert(m_node.chainman));
while (!CheckProofOfWork(block.GetHash(), block.nBits, chainparams.GetConsensus())) ++block.nNonce;