Changeset View
Changeset View
Standalone View
Standalone View
src/validation.cpp
// Copyright (c) 2009-2010 Satoshi Nakamoto | // Copyright (c) 2009-2010 Satoshi Nakamoto | ||||
// Copyright (c) 2009-2018 The Bitcoin Core developers | // Copyright (c) 2009-2018 The Bitcoin Core developers | ||||
// Copyright (c) 2017-2020 The Bitcoin developers | // Copyright (c) 2017-2020 The Bitcoin developers | ||||
// Distributed under the MIT software license, see the accompanying | // Distributed under the MIT software license, see the accompanying | ||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php. | // file COPYING or http://www.opensource.org/licenses/mit-license.php. | ||||
#include <validation.h> | #include <validation.h> | ||||
#include <arith_uint256.h> | #include <arith_uint256.h> | ||||
#include <avalanche.h> | |||||
#include <blockindexworkcomparator.h> | #include <blockindexworkcomparator.h> | ||||
#include <blockvalidity.h> | #include <blockvalidity.h> | ||||
#include <chainparams.h> | #include <chainparams.h> | ||||
#include <checkpoints.h> | #include <checkpoints.h> | ||||
#include <checkqueue.h> | #include <checkqueue.h> | ||||
#include <config.h> | #include <config.h> | ||||
#include <consensus/activation.h> | #include <consensus/activation.h> | ||||
#include <consensus/consensus.h> | #include <consensus/consensus.h> | ||||
▲ Show 20 Lines • Show All 4,246 Lines • ▼ Show 20 Lines | bool CChainState::AcceptBlock(const Config &config, | ||||
// needed. | // needed. | ||||
if (gArgs.GetBoolArg("-parkdeepreorg", true)) { | if (gArgs.GetBoolArg("-parkdeepreorg", true)) { | ||||
const CBlockIndex *pindexFork = m_chain.FindFork(pindex); | const CBlockIndex *pindexFork = m_chain.FindFork(pindex); | ||||
if (pindexFork && pindexFork->nHeight + 1 < m_chain.Height()) { | if (pindexFork && pindexFork->nHeight + 1 < m_chain.Height()) { | ||||
LogPrintf("Park block %s as it would cause a deep reorg.\n", | LogPrintf("Park block %s as it would cause a deep reorg.\n", | ||||
pindex->GetBlockHash().ToString()); | pindex->GetBlockHash().ToString()); | ||||
pindex->nStatus = pindex->nStatus.withParked(); | pindex->nStatus = pindex->nStatus.withParked(); | ||||
setDirtyBlockIndex.insert(pindex); | setDirtyBlockIndex.insert(pindex); | ||||
if (g_avalanche && | |||||
pindex->nChainWork >= m_chain.Tip()->nChainWork) { | |||||
g_avalanche->addBlockToReconcile(pindex); | |||||
} | |||||
} | } | ||||
} | } | ||||
// Header is valid/has work and the merkle tree is good. | // Header is valid/has work and the merkle tree is good. | ||||
// Relay now, but if it does not build on our best tip, let the | // Relay now, but if it does not build on our best tip, let the | ||||
// SendMessages loop relay it. | // SendMessages loop relay it. | ||||
if (!IsInitialBlockDownload() && m_chain.Tip() == pindex->pprev) { | if (!IsInitialBlockDownload() && m_chain.Tip() == pindex->pprev) { | ||||
GetMainSignals().NewPoWValidBlock(pindex, pblock); | GetMainSignals().NewPoWValidBlock(pindex, pblock); | ||||
▲ Show 20 Lines • Show All 1,635 Lines • Show Last 20 Lines |