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

Function MineBlock

src/test/util/mining.cpp:62–75  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

60}
61
62CTxIn MineBlock(const NodeContext& node, const CScript& coinbase_scriptPubKey)
63{
64 auto block = PrepareBlock(node, coinbase_scriptPubKey);
65
66 while (!CheckProofOfWork(block->GetHash(), block->nBits, Params().GetConsensus())) {
67 ++block->nNonce;
68 assert(block->nNonce);
69 }
70
71 bool processed{Assert(node.chainman)->ProcessNewBlock(Params(), block, true, nullptr)};
72 assert(processed);
73
74 return CTxIn{block->vtx[0]->GetHash(), 0};
75}
76
77std::shared_ptr<CBlock> PrepareBlock(const NodeContext& node, const CScript& coinbase_scriptPubKey)
78{

Callers 5

initialize_tx_poolFunction · 0.85
generatetoaddressFunction · 0.85
AssembleBlockFunction · 0.85

Calls 5

PrepareBlockFunction · 0.85
CheckProofOfWorkFunction · 0.85
ProcessNewBlockMethod · 0.80
ParamsClass · 0.50
GetHashMethod · 0.45

Tested by

no test coverage detected