Bitcoin Core  0.19.99
P2P Digital Currency
Classes | Macros | Functions | Variables
validation.cpp File Reference
#include <validation.h>
#include <arith_uint256.h>
#include <chain.h>
#include <chainparams.h>
#include <checkqueue.h>
#include <consensus/consensus.h>
#include <consensus/merkle.h>
#include <consensus/tx_check.h>
#include <consensus/tx_verify.h>
#include <consensus/validation.h>
#include <cuckoocache.h>
#include <flatfile.h>
#include <hash.h>
#include <index/txindex.h>
#include <logging.h>
#include <logging/timer.h>
#include <policy/fees.h>
#include <policy/policy.h>
#include <policy/settings.h>
#include <pow.h>
#include <primitives/block.h>
#include <primitives/transaction.h>
#include <random.h>
#include <reverse_iterator.h>
#include <script/script.h>
#include <script/sigcache.h>
#include <shutdown.h>
#include <timedata.h>
#include <tinyformat.h>
#include <txdb.h>
#include <txmempool.h>
#include <ui_interface.h>
#include <uint256.h>
#include <undo.h>
#include <util/moneystr.h>
#include <util/rbf.h>
#include <util/strencodings.h>
#include <util/system.h>
#include <util/translation.h>
#include <util/validation.h>
#include <validationinterface.h>
#include <warnings.h>
#include <string>
#include <boost/algorithm/string/replace.hpp>
#include <boost/thread.hpp>
Include dependency graph for validation.cpp:

Go to the source code of this file.

Classes

class  WarningBitsConditionChecker
 Threshold condition checker that triggers when unknown versionbits are seen on the network. More...
 
struct  PerBlockConnectTrace
 
class  ConnectTrace
 Used to track blocks whose transactions were applied to the UTXO state as a part of a single ActivateBestChainStep call. More...
 
class  CMainCleanup
 

Macros

#define MICRO   0.000001
 
#define MILLI   0.001
 

Functions

CChainStateChainstateActive ()
 
CChainChainActive ()
 
std::atomic_bool fImporting (false)
 
std::atomic_bool fReindex (false)
 
CBlockIndexLookupBlockIndex (const uint256 &hash)
 
CBlockIndexFindForkInGlobalIndex (const CChain &chain, const CBlockLocator &locator)
 Find the last common block between the parameter chain and a locator. More...
 
static void FindFilesToPruneManual (std::set< int > &setFilesToPrune, int nManualPruneHeight)
 
static void FindFilesToPrune (std::set< int > &setFilesToPrune, uint64_t nPruneAfterHeight)
 Prune block and undo files (blk???.dat and undo???.dat) so that the disk space used is less than a user-defined target. More...
 
bool CheckInputs (const CTransaction &tx, TxValidationState &state, const CCoinsViewCache &inputs, unsigned int flags, bool cacheSigStore, bool cacheFullScriptStore, PrecomputedTransactionData &txdata, std::vector< CScriptCheck > *pvChecks) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
 Check whether all inputs of this transaction are valid (no double spends, scripts & sigs, amounts) This does not modify the UTXO set. More...
 
static FILE * OpenUndoFile (const FlatFilePos &pos, bool fReadOnly)
 Open an undo file (rev?????.dat) More...
 
static FlatFileSeq BlockFileSeq ()
 
static FlatFileSeq UndoFileSeq ()
 
bool CheckFinalTx (const CTransaction &tx, int flags)
 Transaction validation functions. More...
 
bool TestLockPointValidity (const LockPoints *lp)
 Test whether the LockPoints height and time are still valid on the current chain. More...
 
bool CheckSequenceLocks (const CTxMemPool &pool, const CTransaction &tx, int flags, LockPoints *lp, bool useExistingLockPoints)
 Check if transaction will be BIP 68 final in the next block to be created. More...
 
static unsigned int GetBlockScriptFlags (const CBlockIndex *pindex, const Consensus::Params &chainparams)
 
static void LimitMempoolSize (CTxMemPool &pool, size_t limit, std::chrono::seconds age) EXCLUSIVE_LOCKS_REQUIRED(pool.cs
 
 if (expired !=0)
 
pool TrimToSize (limit, &vNoSpendsRemaining)
 
static void UpdateMempoolForReorg (DisconnectedBlockTransactions &disconnectpool, bool fAddToMempool) EXCLUSIVE_LOCKS_REQUIRED(cs_main
 
 while (it !=disconnectpool.queuedTx.get< insertion_order >().rend())
 
disconnectpool queuedTx clear ()
 
mempool UpdateTransactionsFromBlock (vHashUpdate)
 
 LimitMempoolSize (mempool, gArgs.GetArg("-maxmempool", DEFAULT_MAX_MEMPOOL_SIZE) *1000000, std::chrono::hours{gArgs.GetArg("-mempoolexpiry", DEFAULT_MEMPOOL_EXPIRY)})
 
static bool CheckInputsFromMempoolAndCache (const CTransaction &tx, TxValidationState &state, const CCoinsViewCache &view, const CTxMemPool &pool, unsigned int flags, PrecomputedTransactionData &txdata) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
 
static bool AcceptToMemoryPoolWithTime (const CChainParams &chainparams, CTxMemPool &pool, TxValidationState &state, const CTransactionRef &tx, int64_t nAcceptTime, std::list< CTransactionRef > *plTxnReplaced, bool bypass_limits, const CAmount nAbsurdFee, bool test_accept) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
 (try to) add transaction to memory pool with a specified acceptance time More...
 
bool AcceptToMemoryPool (CTxMemPool &pool, TxValidationState &state, const CTransactionRef &tx, std::list< CTransactionRef > *plTxnReplaced, bool bypass_limits, const CAmount nAbsurdFee, bool test_accept)
 (try to) add transaction to memory pool plTxnReplaced will be appended to with all transactions replaced from mempool More...
 
bool GetTransaction (const uint256 &hash, CTransactionRef &txOut, const Consensus::Params &consensusParams, uint256 &hashBlock, const CBlockIndex *const block_index)
 Return transaction in txOut, and if it was found inside a block, its hash is placed in hashBlock. More...
 
static bool WriteBlockToDisk (const CBlock &block, FlatFilePos &pos, const CMessageHeader::MessageStartChars &messageStart)
 
bool ReadBlockFromDisk (CBlock &block, const FlatFilePos &pos, const Consensus::Params &consensusParams)
 Functions for disk access for blocks. More...
 
bool ReadBlockFromDisk (CBlock &block, const CBlockIndex *pindex, const Consensus::Params &consensusParams)
 
bool ReadRawBlockFromDisk (std::vector< uint8_t > &block, const FlatFilePos &pos, const CMessageHeader::MessageStartChars &message_start)
 
bool ReadRawBlockFromDisk (std::vector< uint8_t > &block, const CBlockIndex *pindex, const CMessageHeader::MessageStartChars &message_start)
 
CAmount GetBlockSubsidy (int nHeight, const Consensus::Params &consensusParams)
 
BlockMapBlockIndex ()
 
static void AlertNotify (const std::string &strMessage)
 
static void CheckForkWarningConditions () EXCLUSIVE_LOCKS_REQUIRED(cs_main)
 
static void CheckForkWarningConditionsOnNewFork (CBlockIndex *pindexNewForkTip) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
 
static void InvalidChainFound (CBlockIndex *pindexNew) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
 
void UpdateCoins (const CTransaction &tx, CCoinsViewCache &inputs, CTxUndo &txundo, int nHeight)
 
void UpdateCoins (const CTransaction &tx, CCoinsViewCache &inputs, int nHeight)
 Apply the effects of this transaction on the UTXO set represented by view. More...
 
int GetSpendHeight (const CCoinsViewCache &inputs)
 Return the spend height, which is one more than the inputs.GetBestBlock(). More...
 
void InitScriptExecutionCache ()
 Initializes the script-execution cache. More...
 
static bool UndoWriteToDisk (const CBlockUndo &blockundo, FlatFilePos &pos, const uint256 &hashBlock, const CMessageHeader::MessageStartChars &messageStart)
 
bool UndoReadFromDisk (CBlockUndo &blockundo, const CBlockIndex *pindex)
 
static bool AbortNode (const std::string &strMessage, const std::string &userMessage="", unsigned int prefix=0)
 Abort with a message. More...
 
static bool AbortNode (BlockValidationState &state, const std::string &strMessage, const std::string &userMessage="", unsigned int prefix=0)
 
int ApplyTxInUndo (Coin &&undo, CCoinsViewCache &view, const COutPoint &out)
 Restore the UTXO in a Coin at a given COutPoint. More...
 
static void FlushBlockFile (bool fFinalize=false)
 
static bool FindUndoPos (BlockValidationState &state, int nFile, FlatFilePos &pos, unsigned int nAddSize)
 
static bool WriteUndoDataForBlock (const CBlockUndo &blockundo, BlockValidationState &state, CBlockIndex *pindex, const CChainParams &chainparams)
 
void ThreadScriptCheck (int worker_num)
 Run an instance of the script checking thread. More...
 
VersionBitsCache versionbitscache GUARDED_BY (cs_main)
 
int32_t ComputeBlockVersion (const CBlockIndex *pindexPrev, const Consensus::Params &params)
 Determine what nVersion a new block should use. More...
 
static bool IsScriptWitnessEnabled (const Consensus::Params &params)
 
static void DoWarning (const std::string &strWarning)
 
static void AppendWarning (std::string &res, const std::string &warn)
 Private helper function that concatenates warning messages. More...
 
static void UpdateTip (const CBlockIndex *pindexNew, const CChainParams &chainParams) EXCLUSIVE_LOCKS_REQUIRED(
 Check warning conditions and do some notifications on new chain tip set. More...
 
static bool NotifyHeaderTip () LOCKS_EXCLUDED(cs_main)
 
static void LimitValidationInterfaceQueue () LOCKS_EXCLUDED(cs_main)
 
bool ActivateBestChain (BlockValidationState &state, const CChainParams &chainparams, std::shared_ptr< const CBlock > pblock)
 Find the best known block, and make it the tip of the block chain. More...
 
bool PreciousBlock (BlockValidationState &state, const CChainParams &params, CBlockIndex *pindex)
 Mark a block as precious and reorganize. More...
 
bool InvalidateBlock (BlockValidationState &state, const CChainParams &chainparams, CBlockIndex *pindex)
 Mark a block as invalid. More...
 
void ResetBlockFailureFlags (CBlockIndex *pindex)
 Remove invalidity status from a block and its descendants. More...
 
static bool FindBlockPos (FlatFilePos &pos, unsigned int nAddSize, unsigned int nHeight, uint64_t nTime, bool fKnown=false)
 
static bool CheckBlockHeader (const CBlockHeader &block, BlockValidationState &state, const Consensus::Params &consensusParams, bool fCheckPOW=true)
 
bool CheckBlock (const CBlock &block, BlockValidationState &state, const Consensus::Params &consensusParams, bool fCheckPOW, bool fCheckMerkleRoot)
 Functions for validating blocks and updating the block tree. More...
 
bool IsWitnessEnabled (const CBlockIndex *pindexPrev, const Consensus::Params &params)
 Check whether witness commitments are required for a block, and whether to enforce NULLDUMMY (BIP 147) rules. More...
 
int GetWitnessCommitmentIndex (const CBlock &block)
 Compute at which vout of the block's coinbase transaction the witness commitment occurs, or -1 if not found. More...
 
void UpdateUncommittedBlockStructures (CBlock &block, const CBlockIndex *pindexPrev, const Consensus::Params &consensusParams)
 Update uncommitted block structures (currently: only the witness reserved value). More...
 
std::vector< unsigned char > GenerateCoinbaseCommitment (CBlock &block, const CBlockIndex *pindexPrev, const Consensus::Params &consensusParams)
 Produce the necessary coinbase commitment for a block (modifies the hash, don't call for mined blocks). More...
 
static CBlockIndexGetLastCheckpoint (const CCheckpointData &data) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
 Returns last CBlockIndex* that is a checkpoint. More...
 
static bool ContextualCheckBlockHeader (const CBlockHeader &block, BlockValidationState &state, const CChainParams &params, const CBlockIndex *pindexPrev, int64_t nAdjustedTime) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
 Context-dependent validity checks. More...
 
static bool ContextualCheckBlock (const CBlock &block, BlockValidationState &state, const Consensus::Params &consensusParams, const CBlockIndex *pindexPrev)
 NOTE: This function is not currently invoked by ConnectBlock(), so we should consider upgrade issues if we change which consensus rules are enforced in this function (eg by adding a new consensus rule). More...
 
bool ProcessNewBlockHeaders (const std::vector< CBlockHeader > &headers, BlockValidationState &state, const CChainParams &chainparams, const CBlockIndex **ppindex)
 Process incoming block headers. More...
 
static FlatFilePos SaveBlockToDisk (const CBlock &block, int nHeight, const CChainParams &chainparams, const FlatFilePos *dbp)
 Store block on disk. More...
 
bool ProcessNewBlock (const CChainParams &chainparams, const std::shared_ptr< const CBlock > pblock, bool fForceProcessing, bool *fNewBlock)
 Process an incoming block. More...
 
bool TestBlockValidity (BlockValidationState &state, const CChainParams &chainparams, const CBlock &block, CBlockIndex *pindexPrev, bool fCheckPOW, bool fCheckMerkleRoot)
 Check a block is completely valid from start to finish (only works on top of our current best block) More...
 
uint64_t CalculateCurrentUsage ()
 BLOCK PRUNING CODE. More...
 
void PruneOneBlockFile (const int fileNumber)
 Mark one block file as pruned. More...
 
void UnlinkPrunedFiles (const std::set< int > &setFilesToPrune)
 Actually unlink the specified files. More...
 
void PruneBlockFilesManual (int nManualPruneHeight)
 Prune block files up to a given height. More...
 
FILE * OpenBlockFile (const FlatFilePos &pos, bool fReadOnly)
 Open a block file (blk?????.dat) More...
 
fs::path GetBlockPosFilename (const FlatFilePos &pos)
 Translation to a filesystem path. More...
 
static bool LoadBlockIndexDB (const CChainParams &chainparams) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
 
bool RewindBlockIndex (const CChainParams &params)
 When there are blocks in the active chain with missing data, rewind the chainstate and remove them from the block index. More...
 
void UnloadBlockIndex ()
 Unload database information. More...
 
bool LoadBlockIndex (const CChainParams &chainparams)
 Load the block tree and coins database from disk, initializing state if we're running with -reindex. More...
 
bool LoadGenesisBlock (const CChainParams &chainparams)
 Ensures we have a genesis block in the block tree, possibly writing one to disk. More...
 
bool LoadExternalBlockFile (const CChainParams &chainparams, FILE *fileIn, FlatFilePos *dbp)
 Import blocks from an external file. More...
 
CBlockFileInfoGetBlockFileInfo (size_t n)
 Get block file info entry for one block file. More...
 
ThresholdState VersionBitsTipState (const Consensus::Params &params, Consensus::DeploymentPos pos)
 Get the BIP9 state for a given deployment at the current tip. More...
 
BIP9Stats VersionBitsTipStatistics (const Consensus::Params &params, Consensus::DeploymentPos pos)
 Get the numerical statistics for the BIP9 state for a given deployment at the current tip. More...
 
int VersionBitsTipStateSinceHeight (const Consensus::Params &params, Consensus::DeploymentPos pos)
 Get the block height at which the BIP9 deployment switched into the state for the block building on the current tip. More...
 
bool LoadMempool (CTxMemPool &pool)
 Load the mempool from disk. More...
 
bool DumpMempool (const CTxMemPool &pool)
 Dump the mempool to disk. More...
 
double GuessVerificationProgress (const ChainTxData &data, const CBlockIndex *pindex)
 Guess how far we are in the verification process at the given block index require cs_main if pindex has not been validated yet (because nChainTx might be unset) More...
 

Variables

std::unique_ptr< CChainStateg_chainstate
 
RecursiveMutex cs_main
 Mutex to guard access to validation specific variables, such as reading or changing the chainstate. More...
 
CBlockIndexpindexBestHeader = nullptr
 Best header we've seen so far (used for getheaders queries' starting points). More...
 
Mutex g_best_block_mutex
 
std::condition_variable g_best_block_cv
 
uint256 g_best_block
 
bool g_parallel_script_checks {false}
 Whether there are dedicated script-checking threads running. More...
 
bool fHavePruned = false
 Pruning-related variables and constants. More...
 
bool fPruneMode = false
 True if we're running in -prune mode. More...
 
bool fRequireStandard = true
 
bool fCheckBlockIndex = false
 
bool fCheckpointsEnabled = DEFAULT_CHECKPOINTS_ENABLED
 
size_t nCoinCacheUsage = 5000 * 300
 
uint64_t nPruneTarget = 0
 Number of MiB of block files that we're trying to stay below. More...
 
int64_t nMaxTipAge = DEFAULT_MAX_TIP_AGE
 If the tip is older than this (in seconds), the node is considered to be in initial block download. More...
 
uint256 hashAssumeValid
 Block hash whose ancestors we will assume to have valid scripts without checking them. More...
 
arith_uint256 nMinimumChainWork
 Minimum work we will assume exists on some valid chain. More...
 
CFeeRate minRelayTxFee = CFeeRate(DEFAULT_MIN_RELAY_TX_FEE)
 A fee rate smaller than this is considered zero fee (for relaying, mining and transaction creation) More...
 
CBlockPolicyEstimator feeEstimator
 
std::unique_ptr< CBlockTreeDBpblocktree
 Global variable that points to the active block tree (protected by cs_main) More...
 
std::vector< COutPointvNoSpendsRemaining
 
static for(const COutPoint &removed :vNoSpendsRemaining) bool IsCurrentForFeeEstimation () EXCLUSIVE_LOCKS_REQUIRED(cs_main)
 
static void ::mempool cs
 
std::vector< uint256vHashUpdate
 
auto it = disconnectpool.queuedTx.get<insertion_order>().rbegin()
 
static CBlockIndexpindexBestForkTip = nullptr
 
static CBlockIndexpindexBestForkBase = nullptr
 
static CuckooCache::cache< uint256, SignatureCacheHasherscriptExecutionCache
 
static uint256 scriptExecutionCacheNonce (GetRandHash())
 
static CCheckQueue< CScriptCheckscriptcheckqueue (128)
 
static int64_t nTimeCheck = 0
 
static int64_t nTimeForks = 0
 
static int64_t nTimeVerify = 0
 
static int64_t nTimeConnect = 0
 
static int64_t nTimeIndex = 0
 
static int64_t nTimeCallbacks = 0
 
static int64_t nTimeTotal = 0
 
static int64_t nBlocksTotal = 0
 
static int64_t nTimeReadFromDisk = 0
 
static int64_t nTimeConnectTotal = 0
 
static int64_t nTimeFlush = 0
 
static int64_t nTimeChainState = 0
 
static int64_t nTimePostConnect = 0
 
static const uint64_t MEMPOOL_DUMP_VERSION = 1
 
static CMainCleanup instance_of_cmaincleanup
 

Macro Definition Documentation

◆ MICRO

#define MICRO   0.000001

Definition at line 59 of file validation.cpp.

◆ MILLI

#define MILLI   0.001

Definition at line 60 of file validation.cpp.

Function Documentation

◆ AbortNode() [1/2]

static bool AbortNode ( const std::string &  strMessage,
const std::string &  userMessage = "",
unsigned int  prefix = 0 
)
static

Abort with a message.

Definition at line 1620 of file validation.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ AbortNode() [2/2]

static bool AbortNode ( BlockValidationState state,
const std::string &  strMessage,
const std::string &  userMessage = "",
unsigned int  prefix = 0 
)
static

Definition at line 1633 of file validation.cpp.

Here is the call graph for this function:

◆ AcceptToMemoryPool()

bool AcceptToMemoryPool ( CTxMemPool pool,
TxValidationState state,
const CTransactionRef tx,
std::list< CTransactionRef > *  plTxnReplaced,
bool  bypass_limits,
const CAmount  nAbsurdFee,
bool  test_accept 
)

(try to) add transaction to memory pool plTxnReplaced will be appended to with all transactions replaced from mempool

Definition at line 1061 of file validation.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ AcceptToMemoryPoolWithTime()

static bool AcceptToMemoryPoolWithTime ( const CChainParams chainparams,
CTxMemPool pool,
TxValidationState state,
const CTransactionRef tx,
int64_t  nAcceptTime,
std::list< CTransactionRef > *  plTxnReplaced,
bool  bypass_limits,
const CAmount  nAbsurdFee,
bool  test_accept 
)
static

(try to) add transaction to memory pool with a specified acceptance time

Definition at line 1039 of file validation.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ActivateBestChain()

bool ActivateBestChain ( BlockValidationState state,
const CChainParams chainparams,
std::shared_ptr< const CBlock pblock = std::shared_ptr< const CBlock >() 
)

Find the best known block, and make it the tip of the block chain.

May not be called with cs_main held. May not be called in a validationinterface callback.

Definition at line 2886 of file validation.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ AlertNotify()

static void AlertNotify ( const std::string &  strMessage)
static

Definition at line 1301 of file validation.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ AppendWarning()

static void AppendWarning ( std::string &  res,
const std::string &  warn 
)
static

Private helper function that concatenates warning messages.

Definition at line 2350 of file validation.cpp.

Here is the caller graph for this function:

◆ ApplyTxInUndo()

int ApplyTxInUndo ( Coin &&  undo,
CCoinsViewCache view,
const COutPoint out 
)

Restore the UTXO in a Coin at a given COutPoint.

Parameters
undoThe Coin to be restored.
viewThe coins view to which to apply the changes.
outThe out point that corresponds to the tx input.
Returns
A DisconnectResult as an int

Definition at line 1646 of file validation.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ BlockFileSeq()

static FlatFileSeq BlockFileSeq ( )
static

Definition at line 3985 of file validation.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ BlockIndex()

BlockMap& BlockIndex ( )
Returns
the global block index map.

Definition at line 1296 of file validation.cpp.

Here is the caller graph for this function:

◆ CalculateCurrentUsage()

uint64_t CalculateCurrentUsage ( )

BLOCK PRUNING CODE.

Calculate the amount of disk space the block & undo files currently use.

Definition at line 3825 of file validation.cpp.

Here is the caller graph for this function:

◆ ChainActive()

CChain& ChainActive ( )
Returns
the most-work chain.

Definition at line 91 of file validation.cpp.

◆ ChainstateActive()

mempool removeForReorg & ChainstateActive ( )
Returns
the most-work valid chainstate.

Definition at line 86 of file validation.cpp.

Here is the caller graph for this function:

◆ CheckBlock()

bool CheckBlock ( const CBlock block,
BlockValidationState state,
const Consensus::Params consensusParams,
bool  fCheckPOW = true,
bool  fCheckMerkleRoot = true 
)

Functions for validating blocks and updating the block tree.

Context-independent validity checks

Definition at line 3263 of file validation.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ CheckBlockHeader()

static bool CheckBlockHeader ( const CBlockHeader block,
BlockValidationState state,
const Consensus::Params consensusParams,
bool  fCheckPOW = true 
)
static

Definition at line 3254 of file validation.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ CheckFinalTx()

bool CheckFinalTx ( const CTransaction tx,
int  flags = -1 
)

Transaction validation functions.

Check if transaction will be final in the next block to be created.

Calls IsFinalTx() with current block height and appropriate block time.

See consensus/consensus.h for flag definitions.

Definition at line 188 of file validation.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ CheckForkWarningConditions()

static void CheckForkWarningConditions ( )
static

Definition at line 1321 of file validation.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ CheckForkWarningConditionsOnNewFork()

static void CheckForkWarningConditionsOnNewFork ( CBlockIndex pindexNewForkTip)
static

Definition at line 1362 of file validation.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ CheckInputs()

bool CheckInputs ( const CTransaction tx,
TxValidationState state,
const CCoinsViewCache inputs,
unsigned int  flags,
bool  cacheSigStore,
bool  cacheFullScriptStore,
PrecomputedTransactionData txdata,
std::vector< CScriptCheck > *  pvChecks 
)

Check whether all inputs of this transaction are valid (no double spends, scripts & sigs, amounts) This does not modify the UTXO set.

If pvChecks is not nullptr, script checks are pushed onto it instead of being performed inline. Any script checks which are not necessary (eg due to script execution cache hits) are, obviously, not pushed onto pvChecks/run.

Setting cacheSigStore/cacheFullScriptStore to false will remove elements from the corresponding cache which are matched. This is useful for checking blocks where we will likely never need the cache entry again.

Note that we may set state.reason to NOT_STANDARD for extra soft-fork flags in flags, block-checking callers should probably reset it to CONSENSUS in such cases.

Non-static (and re-declared) in src/test/txvalidationcache_tests.cpp

Definition at line 1485 of file validation.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ CheckInputsFromMempoolAndCache()

static bool CheckInputsFromMempoolAndCache ( const CTransaction tx,
TxValidationState state,
const CCoinsViewCache view,
const CTxMemPool pool,
unsigned int  flags,
PrecomputedTransactionData txdata 
)
static

Definition at line 393 of file validation.cpp.

Here is the call graph for this function:

◆ CheckSequenceLocks()

bool CheckSequenceLocks ( const CTxMemPool pool,
const CTransaction tx,
int  flags,
LockPoints lp = nullptr,
bool  useExistingLockPoints = false 
)

Check if transaction will be BIP 68 final in the next block to be created.

Simulates calling SequenceLocks() with data from the tip of the current active chain. Optionally stores in LockPoints the resulting height and time calculated and the hash of the block needed for calculation or skips the calculation and uses the LockPoints passed in for evaluation. The LockPoints should not be considered valid if CheckSequenceLocks returns false.

See consensus/consensus.h for flag definitions.

Definition at line 238 of file validation.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ clear()

disconnectpool queuedTx clear ( )
Here is the caller graph for this function:

◆ ComputeBlockVersion()

int32_t ComputeBlockVersion ( const CBlockIndex pindexPrev,
const Consensus::Params params 
)

Determine what nVersion a new block should use.

Definition at line 1777 of file validation.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ContextualCheckBlock()

static bool ContextualCheckBlock ( const CBlock block,
BlockValidationState state,
const Consensus::Params consensusParams,
const CBlockIndex pindexPrev 
)
static

NOTE: This function is not currently invoked by ConnectBlock(), so we should consider upgrade issues if we change which consensus rules are enforced in this function (eg by adding a new consensus rule).

See comment in ConnectBlock(). Note that -reindex-chainstate skips the validation that happens here!

Definition at line 3464 of file validation.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ContextualCheckBlockHeader()

static bool ContextualCheckBlockHeader ( const CBlockHeader block,
BlockValidationState state,
const CChainParams params,
const CBlockIndex pindexPrev,
int64_t  nAdjustedTime 
)
static

Context-dependent validity checks.

By "context", we mean only the previous block headers, but not the UTXO set; UTXO-related validity checks are done in ConnectBlock(). NOTE: This function is not currently invoked by ConnectBlock(), so we should consider upgrade issues if we change which consensus rules are enforced in this function (eg by adding a new consensus rule). See comment in ConnectBlock(). Note that -reindex-chainstate skips the validation that happens here!

Definition at line 3417 of file validation.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ DoWarning()

static void DoWarning ( const std::string &  strWarning)
static

Definition at line 2339 of file validation.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ DumpMempool()

bool DumpMempool ( const CTxMemPool pool)

Dump the mempool to disk.

Definition at line 5020 of file validation.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ fImporting()

std::atomic_bool fImporting ( false  )
Here is the caller graph for this function:

◆ FindBlockPos()

static bool FindBlockPos ( FlatFilePos pos,
unsigned int  nAddSize,
unsigned int  nHeight,
uint64_t  nTime,
bool  fKnown = false 
)
static

Definition at line 3183 of file validation.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ FindFilesToPrune()

static void FindFilesToPrune ( std::set< int > &  setFilesToPrune,
uint64_t  nPruneAfterHeight 
)
static

Prune block and undo files (blk???.dat and undo???.dat) so that the disk space used is less than a user-defined target.

The user sets the target (in MB) on the command line or in config file. This will be run on startup and whenever new space is allocated in a block or undo file, staying below the target. Changing back to unpruned requires a reindex (which in this case means the blockchain must be re-downloaded.)

Pruning functions are called from FlushStateToDisk when the global fCheckForPruning flag has been set. Block and undo files are deleted in lock-step (when blk00003.dat is deleted, so is rev00003.dat.) Pruning cannot take place until the longest chain is at least a certain length (100000 on mainnet, 1000 on testnet, 1000 on regtest). Pruning will never delete a block within a defined distance (currently 288) from the active chain's tip. The block index is updated by unsetting HAVE_DATA and HAVE_UNDO for any blocks that were stored in the deleted files. A db flag records the fact that at least some block files have been pruned.

Parameters
[out]setFilesToPruneThe set of file indices that can be unlinked will be returned

Definition at line 3929 of file validation.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ FindFilesToPruneManual()

static void FindFilesToPruneManual ( std::set< int > &  setFilesToPrune,
int  nManualPruneHeight 
)
static

Definition at line 3882 of file validation.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ FindForkInGlobalIndex()

CBlockIndex* FindForkInGlobalIndex ( const CChain chain,
const CBlockLocator locator 
)

Find the last common block between the parameter chain and a locator.

Definition at line 159 of file validation.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ FindUndoPos()

static bool FindUndoPos ( BlockValidationState state,
int  nFile,
FlatFilePos pos,
unsigned int  nAddSize 
)
static

Definition at line 3232 of file validation.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ FlushBlockFile()

static void FlushBlockFile ( bool  fFinalize = false)
static

Definition at line 1732 of file validation.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ fReindex()

std::atomic_bool fReindex ( false  )
Here is the caller graph for this function:

◆ GenerateCoinbaseCommitment()

std::vector<unsigned char> GenerateCoinbaseCommitment ( CBlock block,
const CBlockIndex pindexPrev,
const Consensus::Params consensusParams 
)

Produce the necessary coinbase commitment for a block (modifies the hash, don't call for mined blocks).

Definition at line 3363 of file validation.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetBlockFileInfo()

CBlockFileInfo* GetBlockFileInfo ( size_t  n)

Get block file info entry for one block file.

Definition at line 4916 of file validation.cpp.

Here is the caller graph for this function:

◆ GetBlockPosFilename()

fs::path GetBlockPosFilename ( const FlatFilePos pos)

Translation to a filesystem path.

Definition at line 4004 of file validation.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetBlockScriptFlags()

static unsigned int GetBlockScriptFlags ( const CBlockIndex pindex,
const Consensus::Params chainparams 
)
static

Definition at line 1828 of file validation.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetBlockSubsidy()

CAmount GetBlockSubsidy ( int  nHeight,
const Consensus::Params consensusParams 
)

Definition at line 1220 of file validation.cpp.

Here is the caller graph for this function:

◆ GetLastCheckpoint()

static CBlockIndex* GetLastCheckpoint ( const CCheckpointData data)
static

Returns last CBlockIndex* that is a checkpoint.

Definition at line 3393 of file validation.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetSpendHeight()

int GetSpendHeight ( const CCoinsViewCache inputs)

Return the spend height, which is one more than the inputs.GetBestBlock().

While checking, GetBestBlock() refers to the parent block. (protected by cs_main) This is also true for mempool checks.

Definition at line 1448 of file validation.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetTransaction()

bool GetTransaction ( const uint256 hash,
CTransactionRef txOut,
const Consensus::Params consensusParams,
uint256 hashBlock,
const CBlockIndex *const  block_index 
)

Return transaction in txOut, and if it was found inside a block, its hash is placed in hashBlock.

Retrieve a transaction (from memory pool, or from disk, if possible)

If blockIndex is provided, the transaction is fetched from the corresponding block.

Definition at line 1073 of file validation.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetWitnessCommitmentIndex()

int GetWitnessCommitmentIndex ( const CBlock block)

Compute at which vout of the block's coinbase transaction the witness commitment occurs, or -1 if not found.

Definition at line 3338 of file validation.cpp.

Here is the caller graph for this function:

◆ GUARDED_BY()

Here is the caller graph for this function:

◆ GuessVerificationProgress()

double GuessVerificationProgress ( const ChainTxData data,
const CBlockIndex pindex 
)

Guess how far we are in the verification process at the given block index require cs_main if pindex has not been validated yet (because nChainTx might be unset)

Guess verification progress (as a fraction between 0.0=genesis and 1.0=current tip).

Definition at line 5075 of file validation.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ if()

if ( expired !  = 0)

Definition at line 317 of file validation.cpp.

Here is the caller graph for this function:

◆ InitScriptExecutionCache()

void InitScriptExecutionCache ( )

Initializes the script-execution cache.

Definition at line 1459 of file validation.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ InvalidateBlock()

bool InvalidateBlock ( BlockValidationState state,
const CChainParams chainparams,
CBlockIndex pindex 
)

Mark a block as invalid.

Definition at line 3058 of file validation.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ InvalidChainFound()

static void InvalidChainFound ( CBlockIndex pindexNew)
static

Definition at line 1395 of file validation.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ IsScriptWitnessEnabled()

static bool IsScriptWitnessEnabled ( const Consensus::Params params)
static

Definition at line 1823 of file validation.cpp.

Here is the caller graph for this function:

◆ IsWitnessEnabled()

bool IsWitnessEnabled ( const CBlockIndex pindexPrev,
const Consensus::Params params 
)

Check whether witness commitments are required for a block, and whether to enforce NULLDUMMY (BIP 147) rules.

Note that transaction witness validation rules are always enforced when P2SH is enforced.

Definition at line 3332 of file validation.cpp.

Here is the caller graph for this function:

◆ LimitMempoolSize() [1/2]

static void LimitMempoolSize ( CTxMemPool pool,
size_t  limit,
std::chrono::seconds  age 
)
static
Here is the caller graph for this function:

◆ LimitMempoolSize() [2/2]

LimitMempoolSize ( mempool  ,
gArgs.GetArg("-maxmempool", DEFAULT_MAX_MEMPOOL_SIZE) *  1000000,
std::chrono::hours{gArgs.GetArg("-mempoolexpiry", DEFAULT_MEMPOOL_EXPIRY)}   
)

◆ LimitValidationInterfaceQueue()

static void LimitValidationInterfaceQueue ( )
static

Definition at line 2778 of file validation.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ LoadBlockIndex()

bool LoadBlockIndex ( const CChainParams chainparams)

Load the block tree and coins database from disk, initializing state if we're running with -reindex.

Definition at line 4553 of file validation.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ LoadBlockIndexDB()

static bool LoadBlockIndexDB ( const CChainParams chainparams)
static

Definition at line 4095 of file validation.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ LoadExternalBlockFile()

bool LoadExternalBlockFile ( const CChainParams chainparams,
FILE *  fileIn,
FlatFilePos dbp 
)

Import blocks from an external file.

Definition at line 4605 of file validation.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ LoadGenesisBlock()

bool LoadGenesisBlock ( const CChainParams chainparams)

Ensures we have a genesis block in the block tree, possibly writing one to disk.

Definition at line 4600 of file validation.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ LoadMempool()

bool LoadMempool ( CTxMemPool pool)

Load the mempool from disk.

Definition at line 4943 of file validation.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ LookupBlockIndex()

CBlockIndex* LookupBlockIndex ( const uint256 hash)

Definition at line 152 of file validation.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ NotifyHeaderTip()

static bool NotifyHeaderTip ( )
static

Definition at line 2756 of file validation.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ OpenBlockFile()

FILE* OpenBlockFile ( const FlatFilePos pos,
bool  fReadOnly 
)

Open a block file (blk?????.dat)

Definition at line 3995 of file validation.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ OpenUndoFile()

static FILE * OpenUndoFile ( const FlatFilePos pos,
bool  fReadOnly = false 
)
static

Open an undo file (rev?????.dat)

Definition at line 4000 of file validation.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ PreciousBlock()

bool PreciousBlock ( BlockValidationState state,
const CChainParams params,
CBlockIndex pindex 
)

Mark a block as precious and reorganize.

May not be called in a validationinterface callback.

Definition at line 2918 of file validation.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ProcessNewBlock()

bool ProcessNewBlock ( const CChainParams chainparams,
const std::shared_ptr< const CBlock pblock,
bool  fForceProcessing,
bool *  fNewBlock 
)

Process an incoming block.

This only returns after the best known valid block is made active. Note that it does not, however, guarantee that the specific block passed to it has been checked for validity!

If you want to possibly get feedback on whether pblock is valid, you must install a CValidationInterface (see validationinterface.h) - this will have its BlockChecked method called whenever any block completes validation.

Note that we guarantee that either the proof-of-work is valid on pblock, or (and possibly also) BlockChecked will have been called.

May not be called in a validationinterface callback.

Parameters
[in]pblockThe block we want to process.
[in]fForceProcessingProcess this block even if unrequested; used for non-network block sources and whitelisted peers.
[out]fNewBlockA boolean which is set to indicate if the block was first received via this call
Returns
If the block was processed, independently of block validity

Definition at line 3760 of file validation.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ProcessNewBlockHeaders()

bool ProcessNewBlockHeaders ( const std::vector< CBlockHeader > &  block,
BlockValidationState state,
const CChainParams chainparams,
const CBlockIndex **  ppindex = nullptr 
)

Process incoming block headers.

May not be called in a validationinterface callback.

Parameters
[in]blockThe block headers themselves
[out]stateThis may be set to an Error state if any error occurred processing them
[in]chainparamsThe params for the chain we want to connect to
[out]ppindexIf set, the pointer will be set to point to the last new block index object for the given headers

Definition at line 3633 of file validation.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ PruneBlockFilesManual()

void PruneBlockFilesManual ( int  nManualPruneHeight)

Prune block files up to a given height.

Definition at line 3904 of file validation.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ PruneOneBlockFile()

void PruneOneBlockFile ( const int  fileNumber)

Mark one block file as pruned.

Definition at line 3837 of file validation.cpp.

Here is the caller graph for this function:

◆ ReadBlockFromDisk() [1/2]

bool ReadBlockFromDisk ( CBlock block,
const FlatFilePos pos,
const Consensus::Params consensusParams 
)

Functions for disk access for blocks.

Definition at line 1134 of file validation.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ReadBlockFromDisk() [2/2]

bool ReadBlockFromDisk ( CBlock block,
const CBlockIndex pindex,
const Consensus::Params consensusParams 
)

Definition at line 1158 of file validation.cpp.

Here is the call graph for this function:

◆ ReadRawBlockFromDisk() [1/2]

bool ReadRawBlockFromDisk ( std::vector< uint8_t > &  block,
const FlatFilePos pos,
const CMessageHeader::MessageStartChars message_start 
)

Definition at line 1174 of file validation.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ReadRawBlockFromDisk() [2/2]

bool ReadRawBlockFromDisk ( std::vector< uint8_t > &  block,
const CBlockIndex pindex,
const CMessageHeader::MessageStartChars message_start 
)

Definition at line 1209 of file validation.cpp.

Here is the call graph for this function:

◆ ResetBlockFailureFlags()

void ResetBlockFailureFlags ( CBlockIndex pindex)

Remove invalidity status from a block and its descendants.

Definition at line 3096 of file validation.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ RewindBlockIndex()

bool RewindBlockIndex ( const CChainParams params)

When there are blocks in the active chain with missing data, rewind the chainstate and remove them from the block index.

Definition at line 4504 of file validation.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SaveBlockToDisk()

static FlatFilePos SaveBlockToDisk ( const CBlock block,
int  nHeight,
const CChainParams chainparams,
const FlatFilePos dbp 
)
static

Store block on disk.

If dbp is non-nullptr, the file is known to already reside on disk

Definition at line 3659 of file validation.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ TestBlockValidity()

bool TestBlockValidity ( BlockValidationState state,
const CChainParams chainparams,
const CBlock block,
CBlockIndex pindexPrev,
bool  fCheckPOW,
bool  fCheckMerkleRoot 
)

Check a block is completely valid from start to finish (only works on top of our current best block)

Definition at line 3795 of file validation.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ TestLockPointValidity()

bool TestLockPointValidity ( const LockPoints lp)

Test whether the LockPoints height and time are still valid on the current chain.

Definition at line 220 of file validation.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ThreadScriptCheck()

void ThreadScriptCheck ( int  worker_num)

Run an instance of the script checking thread.

Definition at line 1770 of file validation.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ TrimToSize()

pool TrimToSize ( limit  ,
vNoSpendsRemaining 
)

◆ UndoFileSeq()

static FlatFileSeq UndoFileSeq ( )
static

Definition at line 3990 of file validation.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ UndoReadFromDisk()

bool UndoReadFromDisk ( CBlockUndo blockundo,
const CBlockIndex pindex 
)

Definition at line 1588 of file validation.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ UndoWriteToDisk()

static bool UndoWriteToDisk ( const CBlockUndo blockundo,
FlatFilePos pos,
const uint256 hashBlock,
const CMessageHeader::MessageStartChars messageStart 
)
static

Definition at line 1561 of file validation.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ UnlinkPrunedFiles()

void UnlinkPrunedFiles ( const std::set< int > &  setFilesToPrune)

Actually unlink the specified files.

Definition at line 3871 of file validation.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ UnloadBlockIndex()

void UnloadBlockIndex ( )

Unload database information.

Definition at line 4532 of file validation.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ UpdateCoins() [1/2]

void UpdateCoins ( const CTransaction tx,
CCoinsViewCache inputs,
CTxUndo txundo,
int  nHeight 
)

Definition at line 1421 of file validation.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ UpdateCoins() [2/2]

void UpdateCoins ( const CTransaction tx,
CCoinsViewCache inputs,
int  nHeight 
)

Apply the effects of this transaction on the UTXO set represented by view.

Definition at line 1436 of file validation.cpp.

Here is the call graph for this function:

◆ UpdateMempoolForReorg()

static void UpdateMempoolForReorg ( DisconnectedBlockTransactions disconnectpool,
bool  fAddToMempool 
)
static
Here is the caller graph for this function:

◆ UpdateTip()

static void UpdateTip ( const CBlockIndex pindexNew,
const CChainParams chainParams 
)
static

Check warning conditions and do some notifications on new chain tip set.

Definition at line 2357 of file validation.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ UpdateTransactionsFromBlock()

mempool UpdateTransactionsFromBlock ( vHashUpdate  )

◆ UpdateUncommittedBlockStructures()

void UpdateUncommittedBlockStructures ( CBlock block,
const CBlockIndex pindexPrev,
const Consensus::Params consensusParams 
)

Update uncommitted block structures (currently: only the witness reserved value).

This is safe for submitted blocks.

Definition at line 3351 of file validation.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ VersionBitsTipState()

ThresholdState VersionBitsTipState ( const Consensus::Params params,
Consensus::DeploymentPos  pos 
)

Get the BIP9 state for a given deployment at the current tip.

Definition at line 4923 of file validation.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ VersionBitsTipStateSinceHeight()

int VersionBitsTipStateSinceHeight ( const Consensus::Params params,
Consensus::DeploymentPos  pos 
)

Get the block height at which the BIP9 deployment switched into the state for the block building on the current tip.

Definition at line 4935 of file validation.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ VersionBitsTipStatistics()

BIP9Stats VersionBitsTipStatistics ( const Consensus::Params params,
Consensus::DeploymentPos  pos 
)

Get the numerical statistics for the BIP9 state for a given deployment at the current tip.

Definition at line 4929 of file validation.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ while()

while ( it = disconnectpool.queuedTx.get<insertion_order>().rend())

Definition at line 363 of file validation.cpp.

Here is the call graph for this function:

◆ WriteBlockToDisk()

static bool WriteBlockToDisk ( const CBlock block,
FlatFilePos pos,
const CMessageHeader::MessageStartChars messageStart 
)
static

Definition at line 1113 of file validation.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ WriteUndoDataForBlock()

static bool WriteUndoDataForBlock ( const CBlockUndo blockundo,
BlockValidationState state,
CBlockIndex pindex,
const CChainParams chainparams 
)
static

Definition at line 1749 of file validation.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ cs

void ::mempool cs
Initial value:
{
RecursiveMutex cs_main
Mutex to guard access to validation specific variables, such as reading or changing the chainstate...
Definition: validation.cpp:106
AssertLockHeld(g_cs_orphans)

Definition at line 353 of file validation.cpp.

◆ cs_main

RecursiveMutex cs_main

Mutex to guard access to validation specific variables, such as reading or changing the chainstate.

This may also need to be locked when updating the transaction pool, e.g. on AcceptToMemoryPool. See CTxMemPool::cs comment for details.

The transaction pool has a separate lock to allow reading from it and the chainstate at the same time.

Definition at line 106 of file validation.cpp.

◆ fCheckBlockIndex

bool fCheckBlockIndex = false

Definition at line 118 of file validation.cpp.

◆ fCheckpointsEnabled

bool fCheckpointsEnabled = DEFAULT_CHECKPOINTS_ENABLED

Definition at line 119 of file validation.cpp.

◆ feeEstimator

CTxMemPool mempool & feeEstimator

Definition at line 129 of file validation.cpp.

◆ fHavePruned

bool fHavePruned = false

Pruning-related variables and constants.

True if any block files have ever been pruned.

Definition at line 115 of file validation.cpp.

◆ fPruneMode

bool fPruneMode = false

True if we're running in -prune mode.

Definition at line 116 of file validation.cpp.

◆ fRequireStandard

bool fRequireStandard = true

Definition at line 117 of file validation.cpp.

◆ g_best_block

uint256 g_best_block

Definition at line 111 of file validation.cpp.

◆ g_best_block_cv

std::condition_variable g_best_block_cv

Definition at line 110 of file validation.cpp.

◆ g_best_block_mutex

Mutex g_best_block_mutex

Definition at line 109 of file validation.cpp.

◆ g_chainstate

std::unique_ptr<CChainState> g_chainstate

Definition at line 84 of file validation.cpp.

◆ g_parallel_script_checks

bool g_parallel_script_checks {false}

Whether there are dedicated script-checking threads running.

False indicates all script checking is done on the main threadMessageHandler thread.

Definition at line 112 of file validation.cpp.

◆ hashAssumeValid

uint256 hashAssumeValid

Block hash whose ancestors we will assume to have valid scripts without checking them.

Definition at line 124 of file validation.cpp.

◆ instance_of_cmaincleanup

CMainCleanup instance_of_cmaincleanup
static

Definition at line 5104 of file validation.cpp.

◆ IsCurrentForFeeEstimation

for (const COutPoint& removed : vNoSpendsRemaining) bool IsCurrentForFeeEstimation() EXCLUSIVE_LOCKS_REQUIRED(cs_main)
static

Definition at line 327 of file validation.cpp.

◆ it

auto it = disconnectpool.queuedTx.get<insertion_order>().rbegin()

Definition at line 362 of file validation.cpp.

◆ MEMPOOL_DUMP_VERSION

const uint64_t MEMPOOL_DUMP_VERSION = 1
static

Definition at line 4941 of file validation.cpp.

◆ minRelayTxFee

A fee rate smaller than this is considered zero fee (for relaying, mining and transaction creation)

Definition at line 127 of file validation.cpp.

◆ nBlocksTotal

int64_t nBlocksTotal = 0
static

Definition at line 1883 of file validation.cpp.

◆ nCoinCacheUsage

size_t nCoinCacheUsage = 5000 * 300

Definition at line 120 of file validation.cpp.

◆ nMaxTipAge

int64_t nMaxTipAge = DEFAULT_MAX_TIP_AGE

If the tip is older than this (in seconds), the node is considered to be in initial block download.

Definition at line 122 of file validation.cpp.

◆ nMinimumChainWork

arith_uint256 nMinimumChainWork

Minimum work we will assume exists on some valid chain.

Definition at line 125 of file validation.cpp.

◆ nPruneTarget

uint64_t nPruneTarget = 0

Number of MiB of block files that we're trying to stay below.

Definition at line 121 of file validation.cpp.

◆ nTimeCallbacks

int64_t nTimeCallbacks = 0
static

Definition at line 1881 of file validation.cpp.

◆ nTimeChainState

int64_t nTimeChainState = 0
static

Definition at line 2465 of file validation.cpp.

◆ nTimeCheck

int64_t nTimeCheck = 0
static

Definition at line 1876 of file validation.cpp.

◆ nTimeConnect

int64_t nTimeConnect = 0
static

Definition at line 1879 of file validation.cpp.

◆ nTimeConnectTotal

int64_t nTimeConnectTotal = 0
static

Definition at line 2463 of file validation.cpp.

◆ nTimeFlush

int64_t nTimeFlush = 0
static

Definition at line 2464 of file validation.cpp.

◆ nTimeForks

int64_t nTimeForks = 0
static

Definition at line 1877 of file validation.cpp.

◆ nTimeIndex

int64_t nTimeIndex = 0
static

Definition at line 1880 of file validation.cpp.

◆ nTimePostConnect

int64_t nTimePostConnect = 0
static

Definition at line 2466 of file validation.cpp.

◆ nTimeReadFromDisk

int64_t nTimeReadFromDisk = 0
static

Definition at line 2462 of file validation.cpp.

◆ nTimeTotal

int64_t nTimeTotal = 0
static

Definition at line 1882 of file validation.cpp.

◆ nTimeVerify

int64_t nTimeVerify = 0
static

Definition at line 1878 of file validation.cpp.

◆ pblocktree

std::unique_ptr<CBlockTreeDB> pblocktree

Global variable that points to the active block tree (protected by cs_main)

Definition at line 178 of file validation.cpp.

◆ pindexBestForkBase

CBlockIndex * pindexBestForkBase = nullptr
static

Definition at line 1294 of file validation.cpp.

◆ pindexBestForkTip

CBlockIndex* pindexBestForkTip = nullptr
static

Definition at line 1294 of file validation.cpp.

◆ pindexBestHeader

CBlockIndex* pindexBestHeader = nullptr

Best header we've seen so far (used for getheaders queries' starting points).

Definition at line 108 of file validation.cpp.

◆ scriptcheckqueue

CCheckQueue<CScriptCheck> scriptcheckqueue(128)
static

◆ scriptExecutionCache

CuckooCache::cache<uint256, SignatureCacheHasher> scriptExecutionCache
static

Definition at line 1456 of file validation.cpp.

◆ scriptExecutionCacheNonce

uint256 scriptExecutionCacheNonce(GetRandHash())
static

◆ vHashUpdate

std::vector<uint256> vHashUpdate

Definition at line 355 of file validation.cpp.

◆ vNoSpendsRemaining

std::vector<COutPoint> vNoSpendsRemaining

Definition at line 321 of file validation.cpp.