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/processor.h> | #include <avalanche/processor.h> | ||||
#include <blockvalidity.h> | #include <blockvalidity.h> | ||||
#include <chainparams.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/merkle.h> | #include <consensus/merkle.h> | ||||
#include <consensus/tx_check.h> | #include <consensus/tx_check.h> | ||||
#include <consensus/tx_verify.h> | #include <consensus/tx_verify.h> | ||||
#include <consensus/validation.h> | #include <consensus/validation.h> | ||||
#include <hash.h> | #include <hash.h> | ||||
#include <index/txindex.h> | #include <index/txindex.h> | ||||
#include <policy/fees.h> | #include <policy/fees.h> | ||||
#include <policy/mempool.h> | #include <policy/mempool.h> | ||||
#include <policy/policy.h> | #include <policy/policy.h> | ||||
#include <policy/settings.h> | #include <policy/settings.h> | ||||
#include <pow/pow.h> | #include <pow/pow.h> | ||||
#include <primitives/block.h> | #include <primitives/block.h> | ||||
#include <primitives/blockhash.h> | |||||
#include <primitives/transaction.h> | #include <primitives/transaction.h> | ||||
#include <random.h> | #include <random.h> | ||||
#include <reverse_iterator.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 <shutdown.h> | #include <shutdown.h> | ||||
#include <timedata.h> | #include <timedata.h> | ||||
▲ Show 20 Lines • Show All 3,457 Lines • ▼ Show 20 Lines | bool CheckBlock(const CBlock &block, BlockValidationState &state, | ||||
if (validationOptions.shouldValidatePoW() && | if (validationOptions.shouldValidatePoW() && | ||||
validationOptions.shouldValidateMerkleRoot()) { | validationOptions.shouldValidateMerkleRoot()) { | ||||
block.fChecked = true; | block.fChecked = true; | ||||
} | } | ||||
return true; | return true; | ||||
} | } | ||||
namespace Checkpoints { | |||||
bool CheckBlock(const CCheckpointData &data, int nHeight, | |||||
const BlockHash &hash) { | |||||
const MapCheckpoints &checkpoints = data.mapCheckpoints; | |||||
MapCheckpoints::const_iterator i = checkpoints.find(nHeight); | |||||
if (i == checkpoints.end()) { | |||||
return true; | |||||
} | |||||
return hash == i->second; | |||||
} | |||||
CBlockIndex *GetLastCheckpoint(const CCheckpointData &data) { | |||||
const MapCheckpoints &checkpoints = data.mapCheckpoints; | |||||
for (const MapCheckpoints::value_type &i : reverse_iterate(checkpoints)) { | |||||
const BlockHash &hash = i.second; | |||||
CBlockIndex *pindex = LookupBlockIndex(hash); | |||||
if (pindex) { | |||||
return pindex; | |||||
} | |||||
} | |||||
return nullptr; | |||||
} | |||||
} // namespace Checkpoints | |||||
/** | /** | ||||
* Context-dependent validity checks. | * Context-dependent validity checks. | ||||
* By "context", we mean only the previous block headers, but not the UTXO | * By "context", we mean only the previous block headers, but not the UTXO | ||||
* set; UTXO-related validity checks are done in ConnectBlock(). | * set; UTXO-related validity checks are done in ConnectBlock(). | ||||
* NOTE: This function is not currently invoked by ConnectBlock(), so we | * NOTE: This function is not currently invoked by ConnectBlock(), so we | ||||
* should consider upgrade issues if we change which consensus rules are | * should consider upgrade issues if we change which consensus rules are | ||||
* enforced in this function (eg by adding a new consensus rule). See comment | * enforced in this function (eg by adding a new consensus rule). See comment | ||||
* in ConnectBlock(). | * in ConnectBlock(). | ||||
▲ Show 20 Lines • Show All 2,145 Lines • Show Last 20 Lines |