| 108 | } |
| 109 | |
| 110 | std::shared_ptr<CBlock> MinerTestingSetup::FinalizeBlock(std::shared_ptr<CBlock> pblock) |
| 111 | { |
| 112 | const CBlockIndex* prev_block{WITH_LOCK(::cs_main, return m_node.chainman->m_blockman.LookupBlockIndex(pblock->hashPrevBlock))}; |
| 113 | m_node.chainman->GenerateCoinbaseCommitment(*pblock, prev_block); |
| 114 | |
| 115 | pblock->hashMerkleRoot = BlockMerkleRoot(*pblock); |
| 116 | |
| 117 | while (!CheckProofOfWork(pblock->GetHash(), pblock->nBits, Params().GetConsensus())) { |
| 118 | ++(pblock->nNonce); |
| 119 | } |
| 120 | |
| 121 | // submit block header, so that miner can get the block height from the |
| 122 | // global state and the node has the topology of the chain |
| 123 | BlockValidationState ignored; |
| 124 | BOOST_CHECK(Assert(m_node.chainman)->ProcessNewBlockHeaders({{*pblock}}, true, ignored)); |
| 125 | |
| 126 | return pblock; |
| 127 | } |
| 128 | |
| 129 | // construct a valid block |
| 130 | std::shared_ptr<const CBlock> MinerTestingSetup::GoodBlock(const uint256& prev_hash) |
nothing calls this directly
no test coverage detected