Changeset View
Changeset View
Standalone View
Standalone View
src/validation.cpp
Show First 20 Lines • Show All 1,898 Lines • ▼ Show 20 Lines | LogPrint(BCLog::BENCH, " - Index writing: %.2fms [%.2fs (%.2fms/blk)]\n", | ||||
nTimeIndex * MILLI / nBlocksTotal); | nTimeIndex * MILLI / nBlocksTotal); | ||||
int64_t nTime6 = GetTimeMicros(); | int64_t nTime6 = GetTimeMicros(); | ||||
nTimeCallbacks += nTime6 - nTime5; | nTimeCallbacks += nTime6 - nTime5; | ||||
LogPrint(BCLog::BENCH, " - Callbacks: %.2fms [%.2fs (%.2fms/blk)]\n", | LogPrint(BCLog::BENCH, " - Callbacks: %.2fms [%.2fs (%.2fms/blk)]\n", | ||||
MILLI * (nTime6 - nTime5), nTimeCallbacks * MICRO, | MILLI * (nTime6 - nTime5), nTimeCallbacks * MICRO, | ||||
nTimeCallbacks * MILLI / nBlocksTotal); | nTimeCallbacks * MILLI / nBlocksTotal); | ||||
// If we just activated the replay protection with that block, it means | |||||
// transaction in the mempool are now invalid. As a result, we need to clear | |||||
// the mempool. | |||||
if (IsReplayProtectionEnabled(config, pindex) && | |||||
!IsReplayProtectionEnabled(config, pindex->pprev)) { | |||||
g_mempool.clear(); | |||||
} | |||||
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. | ||||
▲ Show 20 Lines • Show All 476 Lines • ▼ Show 20 Lines | |||||
* by copying pblock) - if that is not intended, care must be taken to remove | * by copying pblock) - if that is not intended, care must be taken to remove | ||||
* the last entry in blocksConnected in case of failure. | * the last entry in blocksConnected in case of failure. | ||||
*/ | */ | ||||
static bool ConnectTip(const Config &config, CValidationState &state, | static bool ConnectTip(const Config &config, CValidationState &state, | ||||
CBlockIndex *pindexNew, | CBlockIndex *pindexNew, | ||||
const std::shared_ptr<const CBlock> &pblock, | const std::shared_ptr<const CBlock> &pblock, | ||||
ConnectTrace &connectTrace, | ConnectTrace &connectTrace, | ||||
DisconnectedBlockTransactions &disconnectpool) { | DisconnectedBlockTransactions &disconnectpool) { | ||||
AssertLockHeld(cs_main); | |||||
assert(pindexNew->pprev == chainActive.Tip()); | assert(pindexNew->pprev == chainActive.Tip()); | ||||
// Read block from disk. | // Read block from disk. | ||||
int64_t nTime1 = GetTimeMicros(); | int64_t nTime1 = GetTimeMicros(); | ||||
std::shared_ptr<const CBlock> pthisBlock; | std::shared_ptr<const CBlock> pthisBlock; | ||||
if (!pblock) { | if (!pblock) { | ||||
std::shared_ptr<CBlock> pblockNew = std::make_shared<CBlock>(); | std::shared_ptr<CBlock> pblockNew = std::make_shared<CBlock>(); | ||||
if (!ReadBlockFromDisk(*pblockNew, pindexNew, config)) { | if (!ReadBlockFromDisk(*pblockNew, pindexNew, config)) { | ||||
return AbortNode(state, "Failed to read block"); | return AbortNode(state, "Failed to read block"); | ||||
▲ Show 20 Lines • Show All 60 Lines • ▼ Show 20 Lines | static bool ConnectTip(const Config &config, CValidationState &state, | ||||
int64_t nTime5 = GetTimeMicros(); | int64_t nTime5 = GetTimeMicros(); | ||||
nTimeChainState += nTime5 - nTime4; | nTimeChainState += nTime5 - nTime4; | ||||
LogPrint(BCLog::BENCH, | LogPrint(BCLog::BENCH, | ||||
" - Writing chainstate: %.2fms [%.2fs (%.2fms/blk)]\n", | " - Writing chainstate: %.2fms [%.2fs (%.2fms/blk)]\n", | ||||
(nTime5 - nTime4) * MILLI, nTimeChainState * MICRO, | (nTime5 - nTime4) * MILLI, nTimeChainState * MICRO, | ||||
nTimeChainState * MILLI / nBlocksTotal); | nTimeChainState * MILLI / nBlocksTotal); | ||||
// If we just activated the replay protection with that block, it means | |||||
// transaction in the mempool are now invalid. As a result, we need to clear | |||||
// the mempool. | |||||
if (IsReplayProtectionEnabled(config, pindexNew) && | |||||
!IsReplayProtectionEnabled(config, pindexNew->pprev)) { | |||||
g_mempool.clear(); | |||||
} | |||||
// Remove conflicting transactions from the mempool.; | // Remove conflicting transactions from the mempool.; | ||||
g_mempool.removeForBlock(blockConnecting.vtx, pindexNew->nHeight); | g_mempool.removeForBlock(blockConnecting.vtx, pindexNew->nHeight); | ||||
disconnectpool.removeForBlock(blockConnecting.vtx); | disconnectpool.removeForBlock(blockConnecting.vtx); | ||||
// Update chainActive & related variables. | // Update chainActive & related variables. | ||||
UpdateTip(config, pindexNew); | UpdateTip(config, pindexNew); | ||||
int64_t nTime6 = GetTimeMicros(); | int64_t nTime6 = GetTimeMicros(); | ||||
nTimePostConnect += nTime6 - nTime5; | nTimePostConnect += nTime6 - nTime5; | ||||
▲ Show 20 Lines • Show All 3,039 Lines • Show Last 20 Lines |