Changeset View
Changeset View
Standalone View
Standalone View
src/validation.cpp
Show First 20 Lines • Show All 1,978 Lines • ▼ Show 20 Lines | bool CChainState::ConnectBlock(const Config &config, const CBlock &block, | ||||
return true; | return true; | ||||
} | } | ||||
/** | /** | ||||
* Update the on-disk chain state. | * Update the on-disk chain state. | ||||
* The caches and indexes are flushed depending on the mode we're called with if | * The caches and indexes are flushed depending on the mode we're called with if | ||||
* they're too large, if it's been a while since the last write, or always and | * they're too large, if it's been a while since the last write, or always and | ||||
* in all cases if we're in prune mode and are deleting files. | * in all cases if we're in prune mode and are deleting files. | ||||
* | |||||
* If FlushStateMode::NONE is used, then FlushStateToDisk(...) won't do anything | |||||
* besides checking if we need to prune. | |||||
*/ | */ | ||||
static bool FlushStateToDisk(const CChainParams &chainparams, | static bool FlushStateToDisk(const CChainParams &chainparams, | ||||
CValidationState &state, FlushStateMode mode, | CValidationState &state, FlushStateMode mode, | ||||
int nManualPruneHeight) { | int nManualPruneHeight) { | ||||
int64_t nMempoolUsage = g_mempool.DynamicMemoryUsage(); | int64_t nMempoolUsage = g_mempool.DynamicMemoryUsage(); | ||||
LOCK(cs_main); | LOCK(cs_main); | ||||
static int64_t nLastWrite = 0; | static int64_t nLastWrite = 0; | ||||
static int64_t nLastFlush = 0; | static int64_t nLastFlush = 0; | ||||
▲ Show 20 Lines • Show All 2,041 Lines • ▼ Show 20 Lines | try { | ||||
} | } | ||||
if (!ReceivedBlockTransactions(block, state, pindex, blockPos)) { | if (!ReceivedBlockTransactions(block, state, pindex, blockPos)) { | ||||
return error("AcceptBlock(): ReceivedBlockTransactions failed"); | return error("AcceptBlock(): ReceivedBlockTransactions failed"); | ||||
} | } | ||||
} catch (const std::runtime_error &e) { | } catch (const std::runtime_error &e) { | ||||
return AbortNode(state, std::string("System error: ") + e.what()); | return AbortNode(state, std::string("System error: ") + e.what()); | ||||
} | } | ||||
if (fCheckForPruning) { | |||||
// we just allocated more disk space for block files. | |||||
FlushStateToDisk(config.GetChainParams(), state, FlushStateMode::NONE); | FlushStateToDisk(config.GetChainParams(), state, FlushStateMode::NONE); | ||||
} | |||||
CheckBlockIndex(chainparams.GetConsensus()); | CheckBlockIndex(chainparams.GetConsensus()); | ||||
return true; | return true; | ||||
} | } | ||||
bool ProcessNewBlock(const Config &config, | bool ProcessNewBlock(const Config &config, | ||||
const std::shared_ptr<const CBlock> pblock, | const std::shared_ptr<const CBlock> pblock, | ||||
▲ Show 20 Lines • Show All 1,607 Lines • Show Last 20 Lines |