| 3605 | |
| 3606 | |
| 3607 | bool 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 | |
| 3635 | bool TestBlockValidity(CValidationState &state, const CBlock& block, CBlockIndex * const pindexPrev, bool fCheckPOW, bool fCheckMerkleRoot) |
| 3636 | { |