Skip to content

Commit 2c3ba00

Browse files
committed
miner: Pass in blockman to ::RegenerateCommitments
REQUIRES ATTENTION
1 parent 2afcf24 commit 2c3ba00

File tree

4 files changed

+5
-5
lines changed

4 files changed

+5
-5
lines changed

src/miner.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,13 @@ int64_t UpdateTime(CBlockHeader* pblock, const Consensus::Params& consensusParam
3939
return nNewTime - nOldTime;
4040
}
4141

42-
void RegenerateCommitments(CBlock& block)
42+
void RegenerateCommitments(CBlock& block, BlockManager& blockman)
4343
{
4444
CMutableTransaction tx{*block.vtx.at(0)};
4545
tx.vout.erase(tx.vout.begin() + GetWitnessCommitmentIndex(block));
4646
block.vtx.at(0) = MakeTransactionRef(tx);
4747

48-
GenerateCoinbaseCommitment(block, WITH_LOCK(cs_main, return g_chainman.m_blockman.LookupBlockIndex(block.hashPrevBlock)), Params().GetConsensus());
48+
GenerateCoinbaseCommitment(block, WITH_LOCK(::cs_main, assert(std::addressof(g_chainman.m_blockman) == std::addressof(blockman)); return blockman.LookupBlockIndex(block.hashPrevBlock)), Params().GetConsensus());
4949

5050
block.hashMerkleRoot = BlockMerkleRoot(block);
5151
}

src/miner.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,6 @@ void IncrementExtraNonce(CBlock* pblock, const CBlockIndex* pindexPrev, unsigned
202202
int64_t UpdateTime(CBlockHeader* pblock, const Consensus::Params& consensusParams, const CBlockIndex* pindexPrev);
203203

204204
/** Update an old GenerateCoinbaseCommitment from CreateNewBlock after the block txs have changed */
205-
void RegenerateCommitments(CBlock& block);
205+
void RegenerateCommitments(CBlock& block, BlockManager& blockman);
206206

207207
#endif // BITCOIN_MINER_H

src/rpc/mining.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,7 @@ static RPCHelpMan generateblock()
369369

370370
// Add transactions
371371
block.vtx.insert(block.vtx.end(), txs.begin(), txs.end());
372-
RegenerateCommitments(block);
372+
RegenerateCommitments(block, WITH_LOCK(::cs_main, return std::ref(g_chainman.m_blockman)));
373373

374374
{
375375
LOCK(cs_main);

src/test/util/setup_common.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ CBlock TestChain100Setup::CreateAndProcessBlock(const std::vector<CMutableTransa
251251
for (const CMutableTransaction& tx : txns) {
252252
block.vtx.push_back(MakeTransactionRef(tx));
253253
}
254-
RegenerateCommitments(block);
254+
RegenerateCommitments(block, WITH_LOCK(::cs_main, return std::ref(g_chainman.m_blockman)));
255255

256256
while (!CheckProofOfWork(block.GetHash(), block.nBits, chainparams.GetConsensus())) ++block.nNonce;
257257

0 commit comments

Comments
 (0)