MCPcopy Create free account
hub / github.com/bitcoin/bitcoin / FinalizeBlock

Method FinalizeBlock

src/test/validation_block_tests.cpp:110–127  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

108}
109
110std::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
130std::shared_ptr<const CBlock> MinerTestingSetup::GoodBlock(const uint256& prev_hash)

Callers

nothing calls this directly

Calls 6

BlockMerkleRootFunction · 0.85
CheckProofOfWorkFunction · 0.85
ParamsClass · 0.50
GetHashMethod · 0.45

Tested by

no test coverage detected