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:
ismaelsadeeq
2025-04-28 17:00:50 +01:00
parent 02d4bc776b
commit e6c2f4ce7a
3 changed files with 18 additions and 16 deletions

View File

@@ -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