Changeset View
Changeset View
Standalone View
Standalone View
src/validation.cpp
Show First 20 Lines • Show All 56 Lines • ▼ Show 20 Lines | |||||
#include <thread> | #include <thread> | ||||
#define MICRO 0.000001 | #define MICRO 0.000001 | ||||
#define MILLI 0.001 | #define MILLI 0.001 | ||||
ChainstateManager g_chainman; | ChainstateManager g_chainman; | ||||
CChainState &ChainstateActive() { | CChainState &ChainstateActive() { | ||||
LOCK(::cs_main); | |||||
assert(g_chainman.m_active_chainstate); | assert(g_chainman.m_active_chainstate); | ||||
return *g_chainman.m_active_chainstate; | return *g_chainman.m_active_chainstate; | ||||
} | } | ||||
CChain &ChainActive() { | CChain &ChainActive() { | ||||
LOCK(::cs_main); | |||||
return ::ChainstateActive().m_chain; | return ::ChainstateActive().m_chain; | ||||
} | } | ||||
/** | /** | ||||
* Global state | * Global state | ||||
* | * | ||||
* Mutex to guard access to validation specific variables, such as reading | * Mutex to guard access to validation specific variables, such as reading | ||||
* or changing the chainstate. | * or changing the chainstate. | ||||
▲ Show 20 Lines • Show All 707 Lines • ▼ Show 20 Lines | bool CChainState::IsInitialBlockDownload() const { | ||||
m_cached_finished_ibd.store(true, std::memory_order_relaxed); | m_cached_finished_ibd.store(true, std::memory_order_relaxed); | ||||
return false; | return false; | ||||
} | } | ||||
static CBlockIndex const *pindexBestForkTip = nullptr; | static CBlockIndex const *pindexBestForkTip = nullptr; | ||||
static CBlockIndex const *pindexBestForkBase = nullptr; | static CBlockIndex const *pindexBestForkBase = nullptr; | ||||
BlockMap &BlockIndex() { | BlockMap &BlockIndex() { | ||||
LOCK(::cs_main); | |||||
return g_chainman.m_blockman.m_block_index; | return g_chainman.m_blockman.m_block_index; | ||||
} | } | ||||
static void AlertNotify(const std::string &strMessage) { | static void AlertNotify(const std::string &strMessage) { | ||||
uiInterface.NotifyAlertChanged(); | uiInterface.NotifyAlertChanged(); | ||||
#if defined(HAVE_SYSTEM) | #if defined(HAVE_SYSTEM) | ||||
std::string strCmd = gArgs.GetArg("-alertnotify", ""); | std::string strCmd = gArgs.GetArg("-alertnotify", ""); | ||||
if (strCmd.empty()) { | if (strCmd.empty()) { | ||||
▲ Show 20 Lines • Show All 4,381 Lines • ▼ Show 20 Lines | try { | ||||
hash.ToString(), pindex->nHeight); | hash.ToString(), pindex->nHeight); | ||||
} | } | ||||
} | } | ||||
// Activate the genesis block so normal node progress can | // Activate the genesis block so normal node progress can | ||||
// continue | // continue | ||||
if (hash == chainparams.GetConsensus().hashGenesisBlock) { | if (hash == chainparams.GetConsensus().hashGenesisBlock) { | ||||
BlockValidationState state; | BlockValidationState state; | ||||
if (!ActivateBestChain(config, state)) { | if (!ActivateBestChain(config, state, nullptr)) { | ||||
break; | break; | ||||
} | } | ||||
} | } | ||||
NotifyHeaderTip(); | NotifyHeaderTip(); | ||||
// Recursively process earlier encountered successors of this | // Recursively process earlier encountered successors of this | ||||
// block | // block | ||||
▲ Show 20 Lines • Show All 690 Lines • Show Last 20 Lines |