Changeset View
Changeset View
Standalone View
Standalone View
src/validation.cpp
Show All 21 Lines | |||||
#include "hash.h" | #include "hash.h" | ||||
#include "init.h" | #include "init.h" | ||||
#include "policy/fees.h" | #include "policy/fees.h" | ||||
#include "policy/policy.h" | #include "policy/policy.h" | ||||
#include "pow.h" | #include "pow.h" | ||||
#include "primitives/block.h" | #include "primitives/block.h" | ||||
#include "primitives/transaction.h" | #include "primitives/transaction.h" | ||||
#include "random.h" | #include "random.h" | ||||
#include "reverse_iterator.h" | |||||
#include "script/script.h" | #include "script/script.h" | ||||
#include "script/scriptcache.h" | #include "script/scriptcache.h" | ||||
#include "script/sigcache.h" | #include "script/sigcache.h" | ||||
#include "script/standard.h" | #include "script/standard.h" | ||||
#include "timedata.h" | #include "timedata.h" | ||||
#include "tinyformat.h" | #include "tinyformat.h" | ||||
#include "txdb.h" | #include "txdb.h" | ||||
#include "txmempool.h" | #include "txmempool.h" | ||||
#include "ui_interface.h" | #include "ui_interface.h" | ||||
#include "undo.h" | #include "undo.h" | ||||
#include "util.h" | #include "util.h" | ||||
#include "utilmoneystr.h" | #include "utilmoneystr.h" | ||||
#include "utilstrencodings.h" | #include "utilstrencodings.h" | ||||
#include "validationinterface.h" | #include "validationinterface.h" | ||||
#include "warnings.h" | #include "warnings.h" | ||||
#include <atomic> | #include <atomic> | ||||
#include <sstream> | #include <sstream> | ||||
#include <thread> | #include <thread> | ||||
#include <boost/algorithm/string/join.hpp> | #include <boost/algorithm/string/join.hpp> | ||||
#include <boost/algorithm/string/replace.hpp> | #include <boost/algorithm/string/replace.hpp> | ||||
#include <boost/range/adaptor/reversed.hpp> | |||||
#include <boost/thread.hpp> | #include <boost/thread.hpp> | ||||
#if defined(NDEBUG) | #if defined(NDEBUG) | ||||
#error "Bitcoin cannot be compiled without assertions." | #error "Bitcoin cannot be compiled without assertions." | ||||
#endif | #endif | ||||
/** | /** | ||||
* Global state | * Global state | ||||
▲ Show 20 Lines • Show All 2,645 Lines • ▼ Show 20 Lines | while (fContinue && nHeight != pindexMostWork->nHeight) { | ||||
while (pindexIter && pindexIter->nHeight != nHeight) { | while (pindexIter && pindexIter->nHeight != nHeight) { | ||||
vpindexToConnect.push_back(pindexIter); | vpindexToConnect.push_back(pindexIter); | ||||
pindexIter = pindexIter->pprev; | pindexIter = pindexIter->pprev; | ||||
} | } | ||||
nHeight = nTargetHeight; | nHeight = nTargetHeight; | ||||
// Connect new blocks. | // Connect new blocks. | ||||
for (CBlockIndex *pindexConnect : | for (CBlockIndex *pindexConnect : reverse_iterate(vpindexToConnect)) { | ||||
boost::adaptors::reverse(vpindexToConnect)) { | |||||
if (!ConnectTip(config, state, pindexConnect, | if (!ConnectTip(config, state, pindexConnect, | ||||
pindexConnect == pindexMostWork | pindexConnect == pindexMostWork | ||||
? pblock | ? pblock | ||||
: std::shared_ptr<const CBlock>(), | : std::shared_ptr<const CBlock>(), | ||||
connectTrace, disconnectpool)) { | connectTrace, disconnectpool)) { | ||||
if (state.IsInvalid()) { | if (state.IsInvalid()) { | ||||
// The block violates a consensus rule. | // The block violates a consensus rule. | ||||
if (!state.CorruptionPossible()) { | if (!state.CorruptionPossible()) { | ||||
▲ Show 20 Lines • Show All 2,801 Lines • Show Last 20 Lines |