Changeset View
Changeset View
Standalone View
Standalone View
src/validation.cpp
Show First 20 Lines • Show All 4,808 Lines • ▼ Show 20 Lines | void CChainState::UnloadBlockIndex() { | ||||
AssertLockHeld(::cs_main); | AssertLockHeld(::cs_main); | ||||
nBlockSequenceId = 1; | nBlockSequenceId = 1; | ||||
setBlockIndexCandidates.clear(); | setBlockIndexCandidates.clear(); | ||||
} | } | ||||
// May NOT be used after any connections are up as much | // May NOT be used after any connections are up as much | ||||
// of the peer-processing logic assumes a consistent | // of the peer-processing logic assumes a consistent | ||||
// block index state | // block index state | ||||
void UnloadBlockIndex(CTxMemPool *mempool, ChainstateManager &chainman) { | void UnloadBlockIndex(ChainstateManager &chainman) { | ||||
AssertLockHeld(::cs_main); | AssertLockHeld(::cs_main); | ||||
chainman.Unload(); | chainman.Unload(); | ||||
pindexBestForkTip = nullptr; | pindexBestForkTip = nullptr; | ||||
pindexBestForkBase = nullptr; | pindexBestForkBase = nullptr; | ||||
if (mempool) { | |||||
mempool->clear(); | |||||
} | |||||
} | } | ||||
bool ChainstateManager::LoadBlockIndex() { | bool ChainstateManager::LoadBlockIndex() { | ||||
AssertLockHeld(cs_main); | AssertLockHeld(cs_main); | ||||
// Load block index from databases | // Load block index from databases | ||||
bool needs_init = fReindex; | bool needs_init = fReindex; | ||||
if (!fReindex) { | if (!fReindex) { | ||||
bool ret = m_blockman.LoadBlockIndexDB(); | bool ret = m_blockman.LoadBlockIndexDB(); | ||||
▲ Show 20 Lines • Show All 1,290 Lines • ▼ Show 20 Lines | if (m_ibd_chainstate && !m_snapshot_chainstate) { | ||||
} else { | } else { | ||||
m_snapshot_chainstate->ResizeCoinsCaches( | m_snapshot_chainstate->ResizeCoinsCaches( | ||||
m_total_coinstip_cache * 0.05, m_total_coinsdb_cache * 0.05); | m_total_coinstip_cache * 0.05, m_total_coinsdb_cache * 0.05); | ||||
m_ibd_chainstate->ResizeCoinsCaches(m_total_coinstip_cache * 0.95, | m_ibd_chainstate->ResizeCoinsCaches(m_total_coinstip_cache * 0.95, | ||||
m_total_coinsdb_cache * 0.95); | m_total_coinsdb_cache * 0.95); | ||||
} | } | ||||
} | } | ||||
} | } | ||||
ChainstateManager::~ChainstateManager() { | |||||
LOCK(::cs_main); | |||||
UnloadBlockIndex(*this); | |||||
} |