MCPcopy Create free account
hub / github.com/ElementsProject/elements / FinalizeBlock

Method FinalizeBlock

src/test/validation_block_tests.cpp:91–108  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

89}
90
91std::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
111std::shared_ptr<const CBlock> MinerTestingSetup::GoodBlock(const uint256& prev_hash)

Callers

nothing calls this directly

Calls 7

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

Tested by

no test coverage detected