MCPcopy Create free account
hub / github.com/bitcoinxt/bitcoinxt / ProcessBlockFound

Function ProcessBlockFound

src/miner.cpp:318–345  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

316}
317
318static bool ProcessBlockFound(CBlock* pblock, CWallet& wallet, CReserveKey& reservekey)
319{
320 LogPrintf("%s\n", pblock->ToString());
321 LogPrintf("generated %s\n", FormatMoney(pblock->vtx[0].vout[0].nValue));
322
323 // Found a solution
324 {
325 LOCK(cs_main);
326 if (pblock->hashPrevBlock != chainActive.Tip()->GetBlockHash())
327 return error("BitcoinMiner: generated block is stale");
328 }
329
330 // Remove key from key pool
331 reservekey.KeepKey();
332
333 // Track how many getdata requests this block gets
334 {
335 LOCK(wallet.cs_wallet);
336 wallet.mapRequestCount[pblock->GetHash()] = 0;
337 }
338
339 // Process this block the same as if we had received it from another node
340 CValidationState state;
341 if (!ProcessNewBlock(state, BlockSource{}, pblock, true, NULL))
342 return error("BitcoinMiner: ProcessNewBlock, block not accepted");
343
344 return true;
345}
346
347void static BitcoinMiner(CWallet *pwallet)
348{

Callers 1

BitcoinMinerFunction · 0.85

Calls 8

FormatMoneyFunction · 0.85
errorFunction · 0.85
ProcessNewBlockFunction · 0.85
KeepKeyMethod · 0.80
ToStringMethod · 0.45
GetBlockHashMethod · 0.45
TipMethod · 0.45
GetHashMethod · 0.45

Tested by

no test coverage detected