Changeset View
Changeset View
Standalone View
Standalone View
src/validation.cpp
Show First 20 Lines • Show All 2,781 Lines • ▼ Show 20 Lines | do { | ||||
// reindex, causing memory blowup if we run too far ahead. | // reindex, causing memory blowup if we run too far ahead. | ||||
// Note that if a validationinterface callback ends up calling | // Note that if a validationinterface callback ends up calling | ||||
// ActivateBestChain this may lead to a deadlock! We should | // ActivateBestChain this may lead to a deadlock! We should | ||||
// probably have a DEBUG_LOCKORDER test for this in the future. | // probably have a DEBUG_LOCKORDER test for this in the future. | ||||
SyncWithValidationInterfaceQueue(); | SyncWithValidationInterfaceQueue(); | ||||
} | } | ||||
{ | { | ||||
LOCK(cs_main); | // Lock transaction pool for at least as long as it takes for | ||||
// connectTrace to be consumed | |||||
LOCK2(cs_main, ::g_mempool.cs); | |||||
CBlockIndex *starting_tip = m_chain.Tip(); | CBlockIndex *starting_tip = m_chain.Tip(); | ||||
bool blocks_connected = false; | bool blocks_connected = false; | ||||
do { | do { | ||||
// We absolutely may not unlock cs_main until we've made forward | // We absolutely may not unlock cs_main until we've made forward | ||||
// progress (with the exception of shutdown due to hardware | // progress (with the exception of shutdown due to hardware | ||||
// issues, low disk space, etc). | // issues, low disk space, etc). | ||||
// Destructed before cs_main is unlocked | // Destructed before cs_main is unlocked | ||||
▲ Show 20 Lines • Show All 146 Lines • ▼ Show 20 Lines | bool CChainState::UnwindBlock(const Config &config, CValidationState &state, | ||||
// Disconnect (descendants of) pindex, and mark them invalid. | // Disconnect (descendants of) pindex, and mark them invalid. | ||||
while (true) { | while (true) { | ||||
if (ShutdownRequested()) { | if (ShutdownRequested()) { | ||||
break; | break; | ||||
} | } | ||||
LOCK(cs_main); | LOCK(cs_main); | ||||
// Lock for as long as disconnectpool is in scope to make sure | |||||
// UpdateMempoolForReorg is called after DisconnectTip without unlocking | |||||
// in between | |||||
LOCK(::g_mempool.cs); | |||||
if (!m_chain.Contains(pindex)) { | if (!m_chain.Contains(pindex)) { | ||||
break; | break; | ||||
} | } | ||||
pindex_was_in_chain = true; | pindex_was_in_chain = true; | ||||
CBlockIndex *invalid_walk_tip = m_chain.Tip(); | CBlockIndex *invalid_walk_tip = m_chain.Tip(); | ||||
▲ Show 20 Lines • Show All 2,673 Lines • Show Last 20 Lines |