Changeset View
Changeset View
Standalone View
Standalone View
src/validation.cpp
Show First 20 Lines • Show All 2,360 Lines • ▼ Show 20 Lines | |||||
* part of a single ActivateBestChainStep call. | * part of a single ActivateBestChainStep call. | ||||
* | * | ||||
* This class is single-use, once you call GetBlocksConnected() you have to | * This class is single-use, once you call GetBlocksConnected() you have to | ||||
* throw it away and make a new one. | * throw it away and make a new one. | ||||
*/ | */ | ||||
class ConnectTrace { | class ConnectTrace { | ||||
private: | private: | ||||
std::vector<PerBlockConnectTrace> blocksConnected; | std::vector<PerBlockConnectTrace> blocksConnected; | ||||
CTxMemPool &pool; | |||||
public: | public: | ||||
explicit ConnectTrace(CTxMemPool &_pool) | explicit ConnectTrace() : blocksConnected(1) {} | ||||
: blocksConnected(1), pool(_pool) {} | |||||
void BlockConnected(CBlockIndex *pindex, | void BlockConnected(CBlockIndex *pindex, | ||||
std::shared_ptr<const CBlock> pblock) { | std::shared_ptr<const CBlock> pblock) { | ||||
assert(!blocksConnected.back().pindex); | assert(!blocksConnected.back().pindex); | ||||
assert(pindex); | assert(pindex); | ||||
assert(pblock); | assert(pblock); | ||||
blocksConnected.back().pindex = pindex; | blocksConnected.back().pindex = pindex; | ||||
blocksConnected.back().pblock = std::move(pblock); | blocksConnected.back().pblock = std::move(pblock); | ||||
▲ Show 20 Lines • Show All 599 Lines • ▼ Show 20 Lines | do { | ||||
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 | ||||
ConnectTrace connectTrace(g_mempool); | ConnectTrace connectTrace; | ||||
if (pindexMostWork == nullptr) { | if (pindexMostWork == nullptr) { | ||||
pindexMostWork = FindMostWorkChain(); | pindexMostWork = FindMostWorkChain(); | ||||
} | } | ||||
// Whether we have anything to do at all. | // Whether we have anything to do at all. | ||||
if (pindexMostWork == nullptr || | if (pindexMostWork == nullptr || | ||||
pindexMostWork == m_chain.Tip()) { | pindexMostWork == m_chain.Tip()) { | ||||
▲ Show 20 Lines • Show All 3,016 Lines • Show Last 20 Lines |