mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-01-25 18:53:23 -03:00
miner: Pass in blockman to ::RegenerateCommitments
REQUIRES ATTENTION
This commit is contained in:
parent
2afcf24408
commit
2c3ba00693
4 changed files with 5 additions and 5 deletions
|
@ -39,13 +39,13 @@ int64_t UpdateTime(CBlockHeader* pblock, const Consensus::Params& consensusParam
|
||||||
return nNewTime - nOldTime;
|
return nNewTime - nOldTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
void RegenerateCommitments(CBlock& block)
|
void RegenerateCommitments(CBlock& block, BlockManager& blockman)
|
||||||
{
|
{
|
||||||
CMutableTransaction tx{*block.vtx.at(0)};
|
CMutableTransaction tx{*block.vtx.at(0)};
|
||||||
tx.vout.erase(tx.vout.begin() + GetWitnessCommitmentIndex(block));
|
tx.vout.erase(tx.vout.begin() + GetWitnessCommitmentIndex(block));
|
||||||
block.vtx.at(0) = MakeTransactionRef(tx);
|
block.vtx.at(0) = MakeTransactionRef(tx);
|
||||||
|
|
||||||
GenerateCoinbaseCommitment(block, WITH_LOCK(cs_main, return g_chainman.m_blockman.LookupBlockIndex(block.hashPrevBlock)), Params().GetConsensus());
|
GenerateCoinbaseCommitment(block, WITH_LOCK(::cs_main, assert(std::addressof(g_chainman.m_blockman) == std::addressof(blockman)); return blockman.LookupBlockIndex(block.hashPrevBlock)), Params().GetConsensus());
|
||||||
|
|
||||||
block.hashMerkleRoot = BlockMerkleRoot(block);
|
block.hashMerkleRoot = BlockMerkleRoot(block);
|
||||||
}
|
}
|
||||||
|
|
|
@ -202,6 +202,6 @@ void IncrementExtraNonce(CBlock* pblock, const CBlockIndex* pindexPrev, unsigned
|
||||||
int64_t UpdateTime(CBlockHeader* pblock, const Consensus::Params& consensusParams, const CBlockIndex* pindexPrev);
|
int64_t UpdateTime(CBlockHeader* pblock, const Consensus::Params& consensusParams, const CBlockIndex* pindexPrev);
|
||||||
|
|
||||||
/** Update an old GenerateCoinbaseCommitment from CreateNewBlock after the block txs have changed */
|
/** Update an old GenerateCoinbaseCommitment from CreateNewBlock after the block txs have changed */
|
||||||
void RegenerateCommitments(CBlock& block);
|
void RegenerateCommitments(CBlock& block, BlockManager& blockman);
|
||||||
|
|
||||||
#endif // BITCOIN_MINER_H
|
#endif // BITCOIN_MINER_H
|
||||||
|
|
|
@ -369,7 +369,7 @@ static RPCHelpMan generateblock()
|
||||||
|
|
||||||
// Add transactions
|
// Add transactions
|
||||||
block.vtx.insert(block.vtx.end(), txs.begin(), txs.end());
|
block.vtx.insert(block.vtx.end(), txs.begin(), txs.end());
|
||||||
RegenerateCommitments(block);
|
RegenerateCommitments(block, WITH_LOCK(::cs_main, return std::ref(g_chainman.m_blockman)));
|
||||||
|
|
||||||
{
|
{
|
||||||
LOCK(cs_main);
|
LOCK(cs_main);
|
||||||
|
|
|
@ -251,7 +251,7 @@ CBlock TestChain100Setup::CreateAndProcessBlock(const std::vector<CMutableTransa
|
||||||
for (const CMutableTransaction& tx : txns) {
|
for (const CMutableTransaction& tx : txns) {
|
||||||
block.vtx.push_back(MakeTransactionRef(tx));
|
block.vtx.push_back(MakeTransactionRef(tx));
|
||||||
}
|
}
|
||||||
RegenerateCommitments(block);
|
RegenerateCommitments(block, WITH_LOCK(::cs_main, return std::ref(g_chainman.m_blockman)));
|
||||||
|
|
||||||
while (!CheckProofOfWork(block.GetHash(), block.nBits, chainparams.GetConsensus())) ++block.nNonce;
|
while (!CheckProofOfWork(block.GetHash(), block.nBits, chainparams.GetConsensus())) ++block.nNonce;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue