Changeset View
Changeset View
Standalone View
Standalone View
src/validation.cpp
Show First 20 Lines • Show All 4,066 Lines • ▼ Show 20 Lines | bool ProcessNewBlock(const Config &config, | ||||
AssertLockNotHeld(cs_main); | AssertLockNotHeld(cs_main); | ||||
{ | { | ||||
if (fNewBlock) { | if (fNewBlock) { | ||||
*fNewBlock = false; | *fNewBlock = false; | ||||
} | } | ||||
CValidationState state; | CValidationState state; | ||||
// Ensure that CheckBlock() passes before calling AcceptBlock, as | |||||
// belt-and-suspenders. | |||||
bool ret = CheckBlock(config, *pblock, state); | |||||
// CheckBlock() does not support multi-threaded block validation | |||||
// because CBlock::fChecked can cause data race. | |||||
// Therefore, the following critical section must include the | |||||
// CheckBlock() call as well. | |||||
LOCK(cs_main); | LOCK(cs_main); | ||||
// Ensure that CheckBlock() passes before calling AcceptBlock, as | |||||
// belt-and-suspenders. | |||||
bool ret = CheckBlock(config, *pblock, state); | |||||
if (ret) { | if (ret) { | ||||
// Store to disk | // Store to disk | ||||
ret = g_chainstate.AcceptBlock( | ret = g_chainstate.AcceptBlock( | ||||
config, pblock, state, fForceProcessing, nullptr, fNewBlock); | config, pblock, state, fForceProcessing, nullptr, fNewBlock); | ||||
} | } | ||||
if (!ret) { | if (!ret) { | ||||
GetMainSignals().BlockChecked(*pblock, state); | GetMainSignals().BlockChecked(*pblock, state); | ||||
▲ Show 20 Lines • Show All 1,602 Lines • Show Last 20 Lines |