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

Function ProcessNewBlock

src/main.cpp:3607–3633  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3605
3606
3607bool ProcessNewBlock(CValidationState &state, const BlockSource& from,
3608 CBlock* pblock, bool fForceProcessing, const CDiskBlockPos *dbp)
3609{
3610 // Preliminary checks
3611 bool checked = CheckBlock(*pblock, state);
3612
3613 {
3614 LOCK(cs_main);
3615 bool fRequested = MarkBlockAsReceived(pblock->GetHash());
3616 fRequested |= fForceProcessing;
3617 if (!checked) {
3618 return error("%s: CheckBlock FAILED", __func__);
3619 }
3620
3621 // Store to disk
3622 CBlockIndex *pindex = NULL;
3623 bool ret = AcceptBlock(*pblock, state, &pindex, fRequested, dbp);
3624 CheckBlockIndex();
3625 if (!ret)
3626 return error("%s: AcceptBlock FAILED", __func__);
3627 }
3628
3629 if (!ActivateBestChain(state, pblock, from))
3630 return error("%s: ActivateBestChain failed", __func__);
3631
3632 return true;
3633}
3634
3635bool TestBlockValidity(CValidationState &state, const CBlock& block, CBlockIndex * const pindexPrev, bool fCheckPOW, bool fCheckMerkleRoot)
3636{

Callers 5

ProcessBlockFoundFunction · 0.85
generateFunction · 0.85
submitblockFunction · 0.85
operator()Method · 0.85
BOOST_AUTO_TEST_CASEFunction · 0.85

Calls 7

MarkBlockAsReceivedFunction · 0.85
errorFunction · 0.85
AcceptBlockFunction · 0.85
CheckBlockIndexFunction · 0.85
ActivateBestChainFunction · 0.85
CheckBlockFunction · 0.70
GetHashMethod · 0.45

Tested by 1

BOOST_AUTO_TEST_CASEFunction · 0.68