mirror of
https://github.com/dashpay/dash.git
synced 2024-12-27 04:52:59 +01:00
Eliminate unnecessary call to CheckBlock
ProcessNewBlock would return failure early if CheckBlock failed, before calling AcceptBlock. AcceptBlock also calls CheckBlock, and upon failure would update mapBlockIndex to indicate that a block was failed. By returning early in ProcessNewBlock, we were not marking blocks that fail a check in CheckBlock as permanently failed, and thus would continue to re-request and reprocess them.
This commit is contained in:
parent
196ad6913f
commit
dbb89dc793
@ -3171,16 +3171,10 @@ static bool IsSuperMajority(int minVersion, const CBlockIndex* pstart, unsigned
|
|||||||
|
|
||||||
bool ProcessNewBlock(CValidationState& state, const CChainParams& chainparams, const CNode* pfrom, const CBlock* pblock, bool fForceProcessing, CDiskBlockPos* dbp)
|
bool ProcessNewBlock(CValidationState& state, const CChainParams& chainparams, const CNode* pfrom, const CBlock* pblock, bool fForceProcessing, CDiskBlockPos* dbp)
|
||||||
{
|
{
|
||||||
// Preliminary checks
|
|
||||||
bool checked = CheckBlock(*pblock, state);
|
|
||||||
|
|
||||||
{
|
{
|
||||||
LOCK(cs_main);
|
LOCK(cs_main);
|
||||||
bool fRequested = MarkBlockAsReceived(pblock->GetHash());
|
bool fRequested = MarkBlockAsReceived(pblock->GetHash());
|
||||||
fRequested |= fForceProcessing;
|
fRequested |= fForceProcessing;
|
||||||
if (!checked) {
|
|
||||||
return error("%s: CheckBlock FAILED %s", __func__, FormatStateMessage(state));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Store to disk
|
// Store to disk
|
||||||
CBlockIndex *pindex = NULL;
|
CBlockIndex *pindex = NULL;
|
||||||
|
Loading…
Reference in New Issue
Block a user