Changeset View
Changeset View
Standalone View
Standalone View
src/validation.cpp
Show All 39 Lines | |||||
#include "undo.h" | #include "undo.h" | ||||
#include "util.h" | #include "util.h" | ||||
#include "utilmoneystr.h" | #include "utilmoneystr.h" | ||||
#include "utilstrencodings.h" | #include "utilstrencodings.h" | ||||
#include "validationinterface.h" | #include "validationinterface.h" | ||||
#include "warnings.h" | #include "warnings.h" | ||||
#include <atomic> | #include <atomic> | ||||
#include <future> | |||||
#include <sstream> | #include <sstream> | ||||
#include <thread> | #include <thread> | ||||
#include <boost/algorithm/string/join.hpp> | #include <boost/algorithm/string/join.hpp> | ||||
#include <boost/algorithm/string/replace.hpp> | #include <boost/algorithm/string/replace.hpp> | ||||
#include <boost/thread.hpp> | #include <boost/thread.hpp> | ||||
#if defined(NDEBUG) | #if defined(NDEBUG) | ||||
▲ Show 20 Lines • Show All 2,795 Lines • ▼ Show 20 Lines | bool ActivateBestChain(const Config &config, CValidationState &state, | ||||
// us in the middle of ProcessNewBlock - do not assume pblock is set | // us in the middle of ProcessNewBlock - do not assume pblock is set | ||||
// sanely for performance or correctness! | // sanely for performance or correctness! | ||||
AssertLockNotHeld(cs_main); | AssertLockNotHeld(cs_main); | ||||
CBlockIndex *pindexMostWork = nullptr; | CBlockIndex *pindexMostWork = nullptr; | ||||
CBlockIndex *pindexNewTip = nullptr; | CBlockIndex *pindexNewTip = nullptr; | ||||
do { | do { | ||||
boost::this_thread::interruption_point(); | boost::this_thread::interruption_point(); | ||||
if (GetMainSignals().CallbacksPending() > 10) { | |||||
// Block until the validation queue drains. This should largely | |||||
// never happen in normal operation, however may happen during | |||||
// reindex, causing memory blowup if we run too far ahead. | |||||
std::promise<void> promise; | |||||
CallFunctionInValidationInterfaceQueue( | |||||
[&promise] { promise.set_value(); }); | |||||
promise.get_future().wait(); | |||||
} | |||||
if (ShutdownRequested()) { | if (ShutdownRequested()) { | ||||
break; | break; | ||||
} | } | ||||
const CBlockIndex *pindexFork; | const CBlockIndex *pindexFork; | ||||
bool fInitialDownload; | bool fInitialDownload; | ||||
{ | { | ||||
LOCK(cs_main); | LOCK(cs_main); | ||||
▲ Show 20 Lines • Show All 2,719 Lines • Show Last 20 Lines |