Bitcoin
Classes | Typedefs | Enumerations | Functions | Variables
validation.h File Reference
#include <amount.h>
#include <coins.h>
#include <crypto/common.h>
#include <fs.h>
#include <policy/feerate.h>
#include <protocol.h>
#include <script/script_error.h>
#include <sync.h>
#include <txmempool.h>
#include <versionbits.h>
#include <algorithm>
#include <atomic>
#include <exception>
#include <map>
#include <memory>
#include <set>
#include <stdint.h>
#include <string>
#include <utility>
#include <vector>

Go to the source code of this file.

Classes

struct  BlockHasher
 
class  CScriptCheck
 
class  CVerifyDB
 
struct  CBlockIndexWorkComparator
 
class  BlockManager
 
class  CChainState
 

Typedefs

typedef std::unordered_map< uint256, CBlockIndex *, BlockHasherBlockMap
 

Enumerations

enum  DisconnectResult { DISCONNECT_OK, DISCONNECT_UNCLEAN, DISCONNECT_FAILED }
 
enum  FlushStateMode { FlushStateMode::NONE, FlushStateMode::IF_NEEDED, FlushStateMode::PERIODIC, FlushStateMode::ALWAYS }
 

Functions

bool ProcessNewBlock (const CChainParams &chainparams, const std::shared_ptr< const CBlock > pblock, bool fForceProcessing, bool *fNewBlock) LOCKS_EXCLUDED(cs_main)
 
bool ProcessNewBlockHeaders (const std::vector< CBlockHeader > &block, CValidationState &state, const CChainParams &chainparams, const CBlockIndex **ppindex=nullptr, CBlockHeader *first_invalid=nullptr) LOCKS_EXCLUDED(cs_main)
 
FILE * OpenBlockFile (const FlatFilePos &pos, bool fReadOnly=false)
 
fs::path GetBlockPosFilename (const FlatFilePos &pos)
 
bool LoadExternalBlockFile (const CChainParams &chainparams, FILE *fileIn, FlatFilePos *dbp=nullptr)
 
bool LoadGenesisBlock (const CChainParams &chainparams)
 
bool LoadBlockIndex (const CChainParams &chainparams) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
 
bool LoadChainTip (const CChainParams &chainparams) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
 
void UnloadBlockIndex ()
 
void ThreadScriptCheck (int worker_num)
 
bool GetTransaction (const uint256 &hash, CTransactionRef &tx, const Consensus::Params &params, uint256 &hashBlock, const CBlockIndex *const blockIndex=nullptr)
 
bool ActivateBestChain (CValidationState &state, const CChainParams &chainparams, std::shared_ptr< const CBlock > pblock=std::shared_ptr< const CBlock >())
 
CAmount GetBlockSubsidy (int nHeight, const Consensus::Params &consensusParams)
 
double GuessVerificationProgress (const ChainTxData &data, const CBlockIndex *pindex)
 
uint64_t CalculateCurrentUsage ()
 
void PruneOneBlockFile (const int fileNumber) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
 
void UnlinkPrunedFiles (const std::set< int > &setFilesToPrune)
 
void PruneBlockFilesManual (int nManualPruneHeight)
 
bool AcceptToMemoryPool (CTxMemPool &pool, CValidationState &state, const CTransactionRef &tx, bool *pfMissingInputs, std::list< CTransactionRef > *plTxnReplaced, bool bypass_limits, const CAmount nAbsurdFee, bool test_accept=false) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
 
ThresholdState VersionBitsTipState (const Consensus::Params &params, Consensus::DeploymentPos pos)
 
BIP9Stats VersionBitsTipStatistics (const Consensus::Params &params, Consensus::DeploymentPos pos)
 
int VersionBitsTipStateSinceHeight (const Consensus::Params &params, Consensus::DeploymentPos pos)
 
void UpdateCoins (const CTransaction &tx, CCoinsViewCache &inputs, int nHeight)
 
bool CheckFinalTx (const CTransaction &tx, int flags=-1) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
 
bool TestLockPointValidity (const LockPoints *lp) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
 
bool CheckSequenceLocks (const CTxMemPool &pool, const CTransaction &tx, int flags, LockPoints *lp=nullptr, bool useExistingLockPoints=false) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
 
void InitScriptExecutionCache ()
 
bool ReadBlockFromDisk (CBlock &block, const FlatFilePos &pos, const Consensus::Params &consensusParams)
 
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)
 
bool UndoReadFromDisk (CBlockUndo &blockundo, const CBlockIndex *pindex)
 
bool CheckBlock (const CBlock &block, CValidationState &state, const Consensus::Params &consensusParams, bool fCheckPOW=true, bool fCheckMerkleRoot=true)
 
bool TestBlockValidity (CValidationState &state, const CChainParams &chainparams, const CBlock &block, CBlockIndex *pindexPrev, bool fCheckPOW=true, bool fCheckMerkleRoot=true) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
 
bool IsWitnessEnabled (const CBlockIndex *pindexPrev, const Consensus::Params &params)
 
bool IsNullDummyEnabled (const CBlockIndex *pindexPrev, const Consensus::Params &params)
 
bool RewindBlockIndex (const CChainParams &params) LOCKS_EXCLUDED(cs_main)
 
void UpdateUncommittedBlockStructures (CBlock &block, const CBlockIndex *pindexPrev, const Consensus::Params &consensusParams)
 
std::vector< unsigned char > GenerateCoinbaseCommitment (CBlock &block, const CBlockIndex *pindexPrev, const Consensus::Params &consensusParams)
 
bool ReplayBlocks (const CChainParams &params, CCoinsView *view)
 
CBlockIndexLookupBlockIndex (const uint256 &hash) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
 
CBlockIndexFindForkInGlobalIndex (const CChain &chain, const CBlockLocator &locator) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
 
bool PreciousBlock (CValidationState &state, const CChainParams &params, CBlockIndex *pindex) LOCKS_EXCLUDED(cs_main)
 
bool InvalidateBlock (CValidationState &state, const CChainParams &chainparams, CBlockIndex *pindex) LOCKS_EXCLUDED(cs_main)
 
void ResetBlockFailureFlags (CBlockIndex *pindex) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
 
CChainStateChainstateActive ()
 
CChainChainActive ()
 
BlockMapBlockIndex ()
 
int GetSpendHeight (const CCoinsViewCache &inputs)
 
int32_t ComputeBlockVersion (const CBlockIndex *pindexPrev, const Consensus::Params &params)
 
CBlockFileInfoGetBlockFileInfo (size_t n)
 
bool DumpMempool (const CTxMemPool &pool)
 
bool LoadMempool (CTxMemPool &pool)
 
bool IsBlockPruned (const CBlockIndex *pblockindex)
 Check whether the block associated with this index entry is pruned or not. More...
 

Variables

static const bool DEFAULT_WHITELISTRELAY = true
 
static const bool DEFAULT_WHITELISTFORCERELAY = false
 
static const unsigned int DEFAULT_MIN_RELAY_TX_FEE = 1000
 
static const unsigned int DEFAULT_ANCESTOR_LIMIT = 25
 
static const unsigned int DEFAULT_ANCESTOR_SIZE_LIMIT = 101
 
static const unsigned int DEFAULT_DESCENDANT_LIMIT = 25
 
static const unsigned int DEFAULT_DESCENDANT_SIZE_LIMIT = 101
 
static const unsigned int DEFAULT_MEMPOOL_EXPIRY = 336
 
static const unsigned int MAX_DISCONNECTED_TX_POOL_SIZE = 20000
 
static const unsigned int MAX_BLOCKFILE_SIZE = 0x8000000
 
static const unsigned int BLOCKFILE_CHUNK_SIZE = 0x1000000
 
static const unsigned int UNDOFILE_CHUNK_SIZE = 0x100000
 
static const int MAX_SCRIPTCHECK_THREADS = 16
 
static const int DEFAULT_SCRIPTCHECK_THREADS = 0
 
static const int MAX_BLOCKS_IN_TRANSIT_PER_PEER = 16
 
static const unsigned int BLOCK_STALLING_TIMEOUT = 2
 
static const unsigned int MAX_HEADERS_RESULTS = 2000
 
static const int MAX_CMPCTBLOCK_DEPTH = 5
 
static const int MAX_BLOCKTXN_DEPTH = 10
 
static const unsigned int BLOCK_DOWNLOAD_WINDOW = 1024
 
static const unsigned int DATABASE_WRITE_INTERVAL = 60 * 60
 
static const unsigned int DATABASE_FLUSH_INTERVAL = 24 * 60 * 60
 
static const unsigned int MAX_REJECT_MESSAGE_LENGTH = 111
 
static const int64_t BLOCK_DOWNLOAD_TIMEOUT_BASE = 1000000
 
static const int64_t BLOCK_DOWNLOAD_TIMEOUT_PER_PEER = 500000
 
static const int64_t DEFAULT_MAX_TIP_AGE = 24 * 60 * 60
 
static const int64_t MAX_FEE_ESTIMATION_TIP_AGE = 3 * 60 * 60
 
static const bool DEFAULT_CHECKPOINTS_ENABLED = true
 
static const bool DEFAULT_TXINDEX = false
 
static const char *const DEFAULT_BLOCKFILTERINDEX = "0"
 
static const unsigned int DEFAULT_BANSCORE_THRESHOLD = 100
 
static const bool DEFAULT_PERSIST_MEMPOOL = true
 
static const bool DEFAULT_FEEFILTER = true
 
static const unsigned int MAX_BLOCKS_TO_ANNOUNCE = 8
 
static const int MAX_UNCONNECTING_HEADERS = 10
 
static const bool DEFAULT_PEERBLOOMFILTERS = true
 
static const int DEFAULT_STOPATHEIGHT = 0
 
CScript COINBASE_FLAGS
 
CCriticalSection cs_main
 
CBlockPolicyEstimator feeEstimator
 
CTxMemPool mempool
 
Mutex g_best_block_mutex
 
std::condition_variable g_best_block_cv
 
uint256 g_best_block
 
std::atomic_bool fImporting
 
std::atomic_bool fReindex
 
int nScriptCheckThreads
 
bool fRequireStandard
 
bool fCheckBlockIndex
 
bool fCheckpointsEnabled
 
size_t nCoinCacheUsage
 
CFeeRate minRelayTxFee
 
int64_t nMaxTipAge
 
uint256 hashAssumeValid
 
arith_uint256 nMinimumChainWork
 
CBlockIndexpindexBestHeader
 
bool fHavePruned
 
bool fPruneMode
 
uint64_t nPruneTarget
 
static const unsigned int MIN_BLOCKS_TO_KEEP = 288
 
static const unsigned int NODE_NETWORK_LIMITED_MIN_BLOCKS = 288
 
static const signed int DEFAULT_CHECKBLOCKS = 6
 
static const unsigned int DEFAULT_CHECKLEVEL = 3
 
static const uint64_t MIN_DISK_SPACE_FOR_BLOCK_FILES = 550 * 1024 * 1024
 
std::unique_ptr< CCoinsViewDBpcoinsdbview
 
std::unique_ptr< CCoinsViewCachepcoinsTip
 
std::unique_ptr< CBlockTreeDBpblocktree
 
VersionBitsCache versionbitscache
 
static const unsigned int REJECT_INTERNAL = 0x100
 
static const unsigned int REJECT_HIGHFEE = 0x100
 

Typedef Documentation

◆ BlockMap

typedef std::unordered_map<uint256, CBlockIndex*, BlockHasher> BlockMap

Enumeration Type Documentation

◆ DisconnectResult

Enumerator
DISCONNECT_OK 
DISCONNECT_UNCLEAN 
DISCONNECT_FAILED 

◆ FlushStateMode

enum FlushStateMode
strong
See also
CChainState::FlushStateToDisk
Enumerator
NONE 
IF_NEEDED 
PERIODIC 
ALWAYS 

Function Documentation

◆ AcceptToMemoryPool()

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

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

◆ ActivateBestChain()

bool ActivateBestChain ( CValidationState 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.

◆ BlockIndex()

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

◆ CalculateCurrentUsage()

uint64_t CalculateCurrentUsage ( )

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

BLOCK PRUNING CODE

◆ ChainActive()

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

◆ ChainstateActive()

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

◆ CheckBlock()

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

Functions for validating blocks and updating the block tree Context-independent validity checks

◆ 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.

◆ 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.

◆ ComputeBlockVersion()

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

Determine what nVersion a new block should use.

◆ DumpMempool()

bool DumpMempool ( const CTxMemPool pool)

Dump the mempool to disk.

◆ FindForkInGlobalIndex()

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

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

◆ 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).

◆ GetBlockFileInfo()

CBlockFileInfo* GetBlockFileInfo ( size_t  n)

Get block file info entry for one block file

◆ GetBlockPosFilename()

fs::path GetBlockPosFilename ( const FlatFilePos pos)

Translation to a filesystem path

◆ GetBlockSubsidy()

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

◆ 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.

◆ GetTransaction()

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

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

Return transaction in txOut, and if it was found inside a block, its hash is placed in hashBlock. If blockIndex is provided, the transaction is fetched from the corresponding block.

◆ GuessVerificationProgress()

double GuessVerificationProgress ( const ChainTxData data,
const CBlockIndex pindex 
)

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

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)

◆ InitScriptExecutionCache()

void InitScriptExecutionCache ( )

Initializes the script-execution cache

◆ InvalidateBlock()

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

Mark a block as invalid.

◆ IsBlockPruned()

bool IsBlockPruned ( const CBlockIndex pblockindex)
inline

Check whether the block associated with this index entry is pruned or not.

◆ IsNullDummyEnabled()

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

Check whether NULLDUMMY (BIP 147) has activated.

◆ IsWitnessEnabled()

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

Check whether witness commitments are required for block.

◆ LoadBlockIndex()

bool LoadBlockIndex ( const CChainParams chainparams)

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

◆ LoadChainTip()

bool LoadChainTip ( const CChainParams chainparams)

Update the chain tip based on database information.

◆ LoadExternalBlockFile()

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

Import blocks from an external file

◆ LoadGenesisBlock()

bool LoadGenesisBlock ( const CChainParams chainparams)

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

◆ LoadMempool()

bool LoadMempool ( CTxMemPool pool)

Load the mempool from disk.

◆ LookupBlockIndex()

CBlockIndex* LookupBlockIndex ( const uint256 hash)

◆ OpenBlockFile()

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

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

◆ PreciousBlock()

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

Mark a block as precious and reorganize.

May not be called in a validationinterface callback.

◆ 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
True if state.IsValid()

◆ ProcessNewBlockHeaders()

bool ProcessNewBlockHeaders ( const std::vector< CBlockHeader > &  block,
CValidationState state,
const CChainParams chainparams,
const CBlockIndex **  ppindex = nullptr,
CBlockHeader first_invalid = 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
[out]first_invalidFirst header that fails validation, if one exists

◆ PruneBlockFilesManual()

void PruneBlockFilesManual ( int  nManualPruneHeight)

Prune block files up to a given height

◆ PruneOneBlockFile()

void PruneOneBlockFile ( const int  fileNumber)

Mark one block file as pruned.

◆ ReadBlockFromDisk() [1/2]

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

Functions for disk access for blocks

◆ ReadBlockFromDisk() [2/2]

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

◆ ReadRawBlockFromDisk() [1/2]

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

◆ ReadRawBlockFromDisk() [2/2]

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

◆ ReplayBlocks()

bool ReplayBlocks ( const CChainParams params,
CCoinsView view 
)

Replay blocks that aren't fully applied to the database.

◆ ResetBlockFailureFlags()

void ResetBlockFailureFlags ( CBlockIndex pindex)

Remove invalidity status from a block and its descendants.

◆ 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

◆ TestBlockValidity()

bool TestBlockValidity ( CValidationState state,
const CChainParams chainparams,
const CBlock block,
CBlockIndex pindexPrev,
bool  fCheckPOW = true,
bool  fCheckMerkleRoot = true 
)

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

◆ TestLockPointValidity()

bool TestLockPointValidity ( const LockPoints lp)

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

◆ ThreadScriptCheck()

void ThreadScriptCheck ( int  worker_num)

Run an instance of the script checking thread

◆ UndoReadFromDisk()

bool UndoReadFromDisk ( CBlockUndo blockundo,
const CBlockIndex pindex 
)

◆ UnlinkPrunedFiles()

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

Actually unlink the specified files

◆ UnloadBlockIndex()

void UnloadBlockIndex ( )

Unload database information

◆ UpdateCoins()

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

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

◆ 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.

◆ VersionBitsTipState()

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

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

◆ 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.

◆ 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.

Variable Documentation

◆ BLOCK_DOWNLOAD_TIMEOUT_BASE

const int64_t BLOCK_DOWNLOAD_TIMEOUT_BASE = 1000000
static

Block download timeout base, expressed in millionths of the block interval (i.e. 10 min)

◆ BLOCK_DOWNLOAD_TIMEOUT_PER_PEER

const int64_t BLOCK_DOWNLOAD_TIMEOUT_PER_PEER = 500000
static

Additional block download timeout per parallel downloading peer (i.e. 5 min)

◆ BLOCK_DOWNLOAD_WINDOW

const unsigned int BLOCK_DOWNLOAD_WINDOW = 1024
static

Size of the "block download window": how far ahead of our current height do we fetch? Larger windows tolerate larger download speed differences between peer, but increase the potential degree of disordering of blocks on disk (which make reindexing and pruning harder). We'll probably want to make this a per-peer adaptive value at some point.

◆ BLOCK_STALLING_TIMEOUT

const unsigned int BLOCK_STALLING_TIMEOUT = 2
static

Timeout in seconds during which a peer must stall block download progress before being disconnected.

◆ BLOCKFILE_CHUNK_SIZE

const unsigned int BLOCKFILE_CHUNK_SIZE = 0x1000000
static

The pre-allocation chunk size for blk?????.dat files (since 0.8)

◆ COINBASE_FLAGS

CScript COINBASE_FLAGS

Constant stuff for coinbase transactions we create:

◆ 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.

◆ DATABASE_FLUSH_INTERVAL

const unsigned int DATABASE_FLUSH_INTERVAL = 24 * 60 * 60
static

Time to wait (in seconds) between flushing chainstate to disk.

◆ DATABASE_WRITE_INTERVAL

const unsigned int DATABASE_WRITE_INTERVAL = 60 * 60
static

Time to wait (in seconds) between writing blocks/block index to disk.

◆ DEFAULT_ANCESTOR_LIMIT

const unsigned int DEFAULT_ANCESTOR_LIMIT = 25
static

Default for -limitancestorcount, max number of in-mempool ancestors

◆ DEFAULT_ANCESTOR_SIZE_LIMIT

const unsigned int DEFAULT_ANCESTOR_SIZE_LIMIT = 101
static

Default for -limitancestorsize, maximum kilobytes of tx + all in-mempool ancestors

◆ DEFAULT_BANSCORE_THRESHOLD

const unsigned int DEFAULT_BANSCORE_THRESHOLD = 100
static

◆ DEFAULT_BLOCKFILTERINDEX

const char* const DEFAULT_BLOCKFILTERINDEX = "0"
static

◆ DEFAULT_CHECKBLOCKS

const signed int DEFAULT_CHECKBLOCKS = 6
static

◆ DEFAULT_CHECKLEVEL

const unsigned int DEFAULT_CHECKLEVEL = 3
static

◆ DEFAULT_CHECKPOINTS_ENABLED

const bool DEFAULT_CHECKPOINTS_ENABLED = true
static

◆ DEFAULT_DESCENDANT_LIMIT

const unsigned int DEFAULT_DESCENDANT_LIMIT = 25
static

Default for -limitdescendantcount, max number of in-mempool descendants

◆ DEFAULT_DESCENDANT_SIZE_LIMIT

const unsigned int DEFAULT_DESCENDANT_SIZE_LIMIT = 101
static

Default for -limitdescendantsize, maximum kilobytes of in-mempool descendants

◆ DEFAULT_FEEFILTER

const bool DEFAULT_FEEFILTER = true
static

Default for using fee filter

◆ DEFAULT_MAX_TIP_AGE

const int64_t DEFAULT_MAX_TIP_AGE = 24 * 60 * 60
static

◆ DEFAULT_MEMPOOL_EXPIRY

const unsigned int DEFAULT_MEMPOOL_EXPIRY = 336
static

Default for -mempoolexpiry, expiration time for mempool transactions in hours

◆ DEFAULT_MIN_RELAY_TX_FEE

const unsigned int DEFAULT_MIN_RELAY_TX_FEE = 1000
static

Default for -minrelaytxfee, minimum relay fee for transactions

◆ DEFAULT_PEERBLOOMFILTERS

const bool DEFAULT_PEERBLOOMFILTERS = true
static

◆ DEFAULT_PERSIST_MEMPOOL

const bool DEFAULT_PERSIST_MEMPOOL = true
static

Default for -persistmempool

◆ DEFAULT_SCRIPTCHECK_THREADS

const int DEFAULT_SCRIPTCHECK_THREADS = 0
static

-par default (number of script-checking threads, 0 = auto)

◆ DEFAULT_STOPATHEIGHT

const int DEFAULT_STOPATHEIGHT = 0
static

Default for -stopatheight

◆ DEFAULT_TXINDEX

const bool DEFAULT_TXINDEX = false
static

◆ DEFAULT_WHITELISTFORCERELAY

const bool DEFAULT_WHITELISTFORCERELAY = false
static

Default for -whitelistforcerelay.

◆ DEFAULT_WHITELISTRELAY

const bool DEFAULT_WHITELISTRELAY = true
static

Default for -whitelistrelay.

◆ fCheckBlockIndex

bool fCheckBlockIndex

◆ fCheckpointsEnabled

bool fCheckpointsEnabled

◆ feeEstimator

CBlockPolicyEstimator feeEstimator

◆ fHavePruned

bool fHavePruned

Pruning-related variables and constants True if any block files have ever been pruned.

◆ fImporting

std::atomic_bool fImporting

◆ fPruneMode

bool fPruneMode

True if we're running in -prune mode.

◆ fReindex

std::atomic_bool fReindex

◆ fRequireStandard

bool fRequireStandard

◆ g_best_block

uint256 g_best_block

◆ g_best_block_cv

std::condition_variable g_best_block_cv

◆ g_best_block_mutex

Mutex g_best_block_mutex

◆ hashAssumeValid

uint256 hashAssumeValid

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

◆ MAX_BLOCKFILE_SIZE

const unsigned int MAX_BLOCKFILE_SIZE = 0x8000000
static

The maximum size of a blk?????.dat file (since 0.8)

◆ MAX_BLOCKS_IN_TRANSIT_PER_PEER

const int MAX_BLOCKS_IN_TRANSIT_PER_PEER = 16
static

Number of blocks that can be requested at any given time from a single peer.

◆ MAX_BLOCKS_TO_ANNOUNCE

const unsigned int MAX_BLOCKS_TO_ANNOUNCE = 8
static

Maximum number of headers to announce when relaying blocks with headers message.

◆ MAX_BLOCKTXN_DEPTH

const int MAX_BLOCKTXN_DEPTH = 10
static

Maximum depth of blocks we're willing to respond to GETBLOCKTXN requests for.

◆ MAX_CMPCTBLOCK_DEPTH

const int MAX_CMPCTBLOCK_DEPTH = 5
static

Maximum depth of blocks we're willing to serve as compact blocks to peers when requested. For older blocks, a regular BLOCK response will be sent.

◆ MAX_DISCONNECTED_TX_POOL_SIZE

const unsigned int MAX_DISCONNECTED_TX_POOL_SIZE = 20000
static

Maximum kilobytes for transactions to store for processing during reorg

◆ MAX_FEE_ESTIMATION_TIP_AGE

const int64_t MAX_FEE_ESTIMATION_TIP_AGE = 3 * 60 * 60
static

Maximum age of our tip in seconds for us to be considered current for fee estimation

◆ MAX_HEADERS_RESULTS

const unsigned int MAX_HEADERS_RESULTS = 2000
static

Number of headers sent in one getheaders result. We rely on the assumption that if a peer sends less than this number, we reached its tip. Changing this value is a protocol upgrade.

◆ MAX_REJECT_MESSAGE_LENGTH

const unsigned int MAX_REJECT_MESSAGE_LENGTH = 111
static

Maximum length of reject messages.

◆ MAX_SCRIPTCHECK_THREADS

const int MAX_SCRIPTCHECK_THREADS = 16
static

Maximum number of script-checking threads allowed

◆ MAX_UNCONNECTING_HEADERS

const int MAX_UNCONNECTING_HEADERS = 10
static

Maximum number of unconnecting headers announcements before DoS score

◆ mempool

CTxMemPool mempool

◆ MIN_BLOCKS_TO_KEEP

const unsigned int MIN_BLOCKS_TO_KEEP = 288
static

Block files containing a block-height within MIN_BLOCKS_TO_KEEP of ChainActive().Tip() will not be pruned.

◆ MIN_DISK_SPACE_FOR_BLOCK_FILES

const uint64_t MIN_DISK_SPACE_FOR_BLOCK_FILES = 550 * 1024 * 1024
static

◆ minRelayTxFee

CFeeRate minRelayTxFee

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

◆ nCoinCacheUsage

size_t nCoinCacheUsage

◆ nMaxTipAge

int64_t nMaxTipAge

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

◆ nMinimumChainWork

arith_uint256 nMinimumChainWork

Minimum work we will assume exists on some valid chain.

◆ NODE_NETWORK_LIMITED_MIN_BLOCKS

const unsigned int NODE_NETWORK_LIMITED_MIN_BLOCKS = 288
static

Minimum blocks required to signal NODE_NETWORK_LIMITED

◆ nPruneTarget

uint64_t nPruneTarget

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

◆ nScriptCheckThreads

int nScriptCheckThreads

◆ pblocktree

std::unique_ptr<CBlockTreeDB> pblocktree

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

◆ pcoinsdbview

std::unique_ptr<CCoinsViewDB> pcoinsdbview

Global variable that points to the coins database (protected by cs_main)

◆ pcoinsTip

std::unique_ptr<CCoinsViewCache> pcoinsTip

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

◆ pindexBestHeader

CBlockIndex* pindexBestHeader

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

◆ REJECT_HIGHFEE

const unsigned int REJECT_HIGHFEE = 0x100
static

Too high fee. Can not be triggered by P2P transactions

◆ REJECT_INTERNAL

const unsigned int REJECT_INTERNAL = 0x100
static

Reject codes greater or equal to this can be returned by AcceptToMemPool for transactions, to signal internal conditions. They cannot and should not be sent over the P2P network.

◆ UNDOFILE_CHUNK_SIZE

const unsigned int UNDOFILE_CHUNK_SIZE = 0x100000
static

The pre-allocation chunk size for rev?????.dat files (since 0.8)

◆ versionbitscache

VersionBitsCache versionbitscache