| 89 | } |
| 90 | |
| 91 | std::shared_ptr<CBlock> MinerTestingSetup::FinalizeBlock(std::shared_ptr<CBlock> pblock) |
| 92 | { |
| 93 | const CBlockIndex* prev_block{WITH_LOCK(::cs_main, return m_node.chainman->m_blockman.LookupBlockIndex(pblock->hashPrevBlock))}; |
| 94 | GenerateCoinbaseCommitment(*pblock, prev_block, Params().GetConsensus()); |
| 95 | |
| 96 | pblock->hashMerkleRoot = BlockMerkleRoot(*pblock); |
| 97 | |
| 98 | while (!CheckProofOfWork(pblock->GetHash(), pblock->nBits, Params().GetConsensus())) { |
| 99 | ++(pblock->nNonce); |
| 100 | } |
| 101 | |
| 102 | // submit block header, so that miner can get the block height from the |
| 103 | // global state and the node has the topology of the chain |
| 104 | BlockValidationState ignored; |
| 105 | BOOST_CHECK(Assert(m_node.chainman)->ProcessNewBlockHeaders({pblock->GetBlockHeader()}, ignored, Params())); |
| 106 | |
| 107 | return pblock; |
| 108 | } |
| 109 | |
| 110 | // construct a valid block |
| 111 | std::shared_ptr<const CBlock> MinerTestingSetup::GoodBlock(const uint256& prev_hash) |
nothing calls this directly
no test coverage detected