mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-04-21 20:28:59 +02:00
interfaces: refactor: move submitSolution implementation to miner
- Create a new function `AddMerkleRootAndCoinbase` that compute the block's merkle root, insert the coinbase transaction and the merkle root into the block.
This commit is contained in:
@@ -434,4 +434,17 @@ void BlockAssembler::addPackageTxs(int& nPackagesSelected, int& nDescendantsUpda
|
||||
nDescendantsUpdated += UpdatePackagesForAdded(mempool, ancestors, mapModifiedTx);
|
||||
}
|
||||
}
|
||||
|
||||
void AddMerkleRootAndCoinbase(CBlock& block, CTransactionRef coinbase, uint32_t version, uint32_t timestamp, uint32_t nonce)
|
||||
{
|
||||
if (block.vtx.size() == 0) {
|
||||
block.vtx.emplace_back(coinbase);
|
||||
} else {
|
||||
block.vtx[0] = coinbase;
|
||||
}
|
||||
block.nVersion = version;
|
||||
block.nTime = timestamp;
|
||||
block.nNonce = nonce;
|
||||
block.hashMerkleRoot = BlockMerkleRoot(block);
|
||||
}
|
||||
} // namespace node
|
||||
|
||||
Reference in New Issue
Block a user