Changeset View
Changeset View
Standalone View
Standalone View
src/test/util/mining.cpp
Show All 34 Lines | CTxIn MineBlock(const Config &config, const NodeContext &node, | ||||
auto block = PrepareBlock(config, node, coinbase_scriptPubKey); | auto block = PrepareBlock(config, node, coinbase_scriptPubKey); | ||||
while (!CheckProofOfWork(block->GetHash(), block->nBits, | while (!CheckProofOfWork(block->GetHash(), block->nBits, | ||||
config.GetChainParams().GetConsensus())) { | config.GetChainParams().GetConsensus())) { | ||||
++block->nNonce; | ++block->nNonce; | ||||
assert(block->nNonce); | assert(block->nNonce); | ||||
} | } | ||||
bool processed{Assert(node.chainman) | bool processed{ | ||||
->ProcessNewBlock(config, block, true, true, nullptr)}; | Assert(node.chainman)->ProcessNewBlock(block, true, true, nullptr)}; | ||||
assert(processed); | assert(processed); | ||||
return CTxIn{block->vtx[0]->GetId(), 0}; | return CTxIn{block->vtx[0]->GetId(), 0}; | ||||
} | } | ||||
std::shared_ptr<CBlock> PrepareBlock(const Config &config, | std::shared_ptr<CBlock> PrepareBlock(const Config &config, | ||||
const NodeContext &node, | const NodeContext &node, | ||||
const CScript &coinbase_scriptPubKey) { | const CScript &coinbase_scriptPubKey) { | ||||
▲ Show 20 Lines • Show All 45 Lines • Show Last 20 Lines |