BSHA3  0.17.99
P2P Blockchain, based on Bitcoin
Classes | Typedefs | Functions | Variables
validation.h File Reference
#include <amount.h>
#include <coins.h>
#include <fs.h>
#include <protocol.h>
#include <policy/feerate.h>
#include <script/script_error.h>
#include <sync.h>
#include <versionbits.h>
#include <algorithm>
#include <exception>
#include <map>
#include <memory>
#include <set>
#include <stdint.h>
#include <string>
#include <utility>
#include <vector>
#include <atomic>
Include dependency graph for validation.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  BlockHasher
 
class  CScriptCheck
 Closure representing one script verification Note that this stores references to the spending transaction. More...
 
class  CVerifyDB
 RAII wrapper for VerifyDB: Verify consistency of the block and coin databases. More...
 

Typedefs

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

Functions

bool ProcessNewBlock (const CChainParams &chainparams, const std::shared_ptr< const CBlock > pblock, bool fForceProcessing, bool *fNewBlock) LOCKS_EXCLUDED(cs_main)
 Process an incoming block. More...
 
bool ProcessNewBlockHeaders (const std::vector< CBlockHeader > &block, CValidationState &state, const CChainParams &chainparams, const CBlockIndex **ppindex=nullptr, CBlockHeader *first_invalid=nullptr) LOCKS_EXCLUDED(cs_main)
 Process incoming block headers. More...
 
bool CheckDiskSpace (uint64_t nAdditionalBytes=0, bool blocks_dir=false)
 Check whether enough disk space is available for an incoming block. More...
 
FILE * OpenBlockFile (const CDiskBlockPos &pos, bool fReadOnly=false)
 Open a block file (blk?????.dat) More...
 
fs::path GetBlockPosFilename (const CDiskBlockPos &pos, const char *prefix)
 Translation to a filesystem path. More...
 
bool LoadExternalBlockFile (const CChainParams &chainparams, FILE *fileIn, CDiskBlockPos *dbp=nullptr)
 Import blocks from an external file. More...
 
bool LoadGenesisBlock (const CChainParams &chainparams)
 Ensures we have a genesis block in the block tree, possibly writing one to disk. More...
 
bool LoadBlockIndex (const CChainParams &chainparams) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
 Load the block tree and coins database from disk, initializing state if we're running with -reindex. More...
 
bool LoadChainTip (const CChainParams &chainparams) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
 Update the chain tip based on database information. More...
 
void UnloadBlockIndex ()
 Unload database information. More...
 
void ThreadScriptCheck ()
 Run an instance of the script checking thread. More...
 
bool IsInitialBlockDownload ()
 Check whether we are doing an initial block download (synchronizing from disk or network) More...
 
bool GetTransaction (const uint256 &hash, CTransactionRef &tx, const Consensus::Params &params, uint256 &hashBlock, bool fAllowSlow=false, CBlockIndex *blockIndex=nullptr)
 Retrieve a transaction (from memory pool, or from disk, if possible) More...
 
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. More...
 
CAmount GetBlockSubsidy (int nHeight, const Consensus::Params &consensusParams)
 
double GuessVerificationProgress (const ChainTxData &data, const CBlockIndex *pindex)
 Guess verification progress (as a fraction between 0.0=genesis and 1.0=current tip). More...
 
uint64_t CalculateCurrentUsage ()
 Calculate the amount of disk space the block & undo files currently use. 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 FlushStateToDisk ()
 Flush all state, indexes and buffers to disk. More...
 
void PruneAndFlush ()
 Prune block files and flush state to disk. More...
 
void PruneBlockFilesManual (int nManualPruneHeight)
 Prune block files up to a given height. More...
 
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)
 (try to) add transaction to memory pool plTxnReplaced will be appended to with all transactions replaced from mempool More...
 
std::string FormatStateMessage (const CValidationState &state)
 Convert CValidationState to a human-readable message for logging. 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...
 
void UpdateCoins (const CTransaction &tx, CCoinsViewCache &inputs, int nHeight)
 Apply the effects of this transaction on the UTXO set represented by view. More...
 
bool CheckFinalTx (const CTransaction &tx, int flags=-1) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
 Transaction validation functions. More...
 
bool TestLockPointValidity (const LockPoints *lp) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
 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=nullptr, bool useExistingLockPoints=false) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
 Check if transaction will be BIP 68 final in the next block to be created. More...
 
void InitScriptExecutionCache ()
 Initializes the script-execution cache. More...
 
bool ReadBlockFromDisk (CBlock &block, const CDiskBlockPos &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 CDiskBlockPos &pos, const CMessageHeader::MessageStartChars &message_start)
 
bool ReadRawBlockFromDisk (std::vector< uint8_t > &block, const CBlockIndex *pindex, const CMessageHeader::MessageStartChars &message_start)
 
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. More...
 
bool TestBlockValidity (CValidationState &state, const CChainParams &chainparams, const CBlock &block, CBlockIndex *pindexPrev, bool fCheckPOW=true, bool fCheckMerkleRoot=true) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
 Check a block is completely valid from start to finish (only works on top of our current best block) More...
 
bool IsWitnessEnabled (const CBlockIndex *pindexPrev, const Consensus::Params &params)
 Check whether witness commitments are required for block. More...
 
bool IsNullDummyEnabled (const CBlockIndex *pindexPrev, const Consensus::Params &params)
 Check whether NULLDUMMY (BIP 147) has activated. More...
 
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 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...
 
bool ReplayBlocks (const CChainParams &params, CCoinsView *view)
 Replay blocks that aren't fully applied to the database. More...
 
CBlockIndexLookupBlockIndex (const uint256 &hash)
 
CBlockIndexFindForkInGlobalIndex (const CChain &chain, const CBlockLocator &locator) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
 Find the last common block between the parameter chain and a locator. More...
 
bool PreciousBlock (CValidationState &state, const CChainParams &params, CBlockIndex *pindex) LOCKS_EXCLUDED(cs_main)
 Mark a block as precious and reorganize. More...
 
bool InvalidateBlock (CValidationState &state, const CChainParams &chainparams, CBlockIndex *pindex) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
 Mark a block as invalid. More...
 
void ResetBlockFailureFlags (CBlockIndex *pindex) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
 Remove invalidity status from a block and its descendants. More...
 
int GetSpendHeight (const CCoinsViewCache &inputs)
 Return the spend height, which is one more than the inputs.GetBestBlock(). More...
 
int32_t ComputeBlockVersion (const CBlockIndex *pindexPrev, const Consensus::Params &params)
 Determine what nVersion a new block should use. More...
 
CBlockFileInfoGetBlockFileInfo (size_t n)
 Get block file info entry for one block file. More...
 
bool DumpMempool ()
 Dump the mempool to disk. More...
 
bool LoadMempool ()
 Load the mempool from disk. More...
 
bool IsBlockPruned (const CBlockIndex *pblockindex)
 Check whether the block associated with this index entry is pruned or not. More...
 

Variables

CScript COINBASE_FLAGS
 Constant stuff for coinbase transactions we create: More...
 
CCriticalSection cs_main
 
CBlockPolicyEstimator feeEstimator
 
CTxMemPool mempool
 
std::atomic_bool g_is_mempool_loaded
 
BlockMapmapBlockIndex
 
uint64_t nLastBlockTx
 
uint64_t nLastBlockWeight
 
const std::string strMessageMagic
 
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 fIsBareMultisigStd
 
bool fRequireStandard
 
bool fCheckBlockIndex
 
bool fCheckpointsEnabled
 
size_t nCoinCacheUsage
 
CFeeRate minRelayTxFee
 A fee rate smaller than this is considered zero fee (for relaying, mining and transaction creation) More...
 
CAmount maxTxFee
 Absolute maximum transaction fee (in satoshis) used by wallet and mempool (rejects high fee in sendrawtransaction) More...
 
int64_t nMaxTipAge
 If the tip is older than this (in seconds), the node is considered to be in initial block download. More...
 
bool fEnableReplacement
 
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...
 
CBlockIndexpindexBestHeader
 Best header we've seen so far (used for getheaders queries' starting points). More...
 
bool fHavePruned
 Pruning-related variables and constants. More...
 
bool fPruneMode
 True if we're running in -prune mode. More...
 
uint64_t nPruneTarget
 Number of MiB of block files that we're trying to stay below. More...
 
CChainchainActive
 The currently-connected chain of blocks (protected by cs_main). More...
 
std::unique_ptr< CCoinsViewDBpcoinsdbview
 Global variable that points to the coins database (protected by cs_main) More...
 
std::unique_ptr< CCoinsViewCachepcoinsTip
 Global variable that points to the active CCoinsView (protected by cs_main) More...
 
std::unique_ptr< CBlockTreeDBpblocktree
 Global variable that points to the active block tree (protected by cs_main) More...
 
VersionBitsCache versionbitscache
 

Typedef Documentation

◆ BlockMap

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

Definition at line 149 of file validation.h.

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

Definition at line 986 of file validation.cpp.

Here is the call graph for this function:

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

Definition at line 2676 of file validation.cpp.

Here is the call graph for this function:

◆ CalculateCurrentUsage()

uint64_t CalculateCurrentUsage ( )

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

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

Definition at line 3518 of file validation.cpp.

Here is the caller graph for this function:

◆ 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

Definition at line 2998 of file validation.cpp.

Here is the caller graph for this function:

◆ CheckDiskSpace()

bool CheckDiskSpace ( uint64_t  nAdditionalBytes = 0,
bool  blocks_dir = false 
)

Check whether enough disk space is available for an incoming block.

Definition at line 3677 of file validation.cpp.

Here is the call 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 315 of file validation.cpp.

Here is the call graph for this function:
Here is the caller 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 365 of file validation.cpp.

Here is the call graph for this function:
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 1687 of file validation.cpp.

Here is the caller graph for this function:

◆ DumpMempool()

bool DumpMempool ( )

Dump the mempool to disk.

Definition at line 4690 of file validation.cpp.

Here is the call 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 278 of file validation.cpp.

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

◆ FlushStateToDisk()

void FlushStateToDisk ( )

Flush all state, indexes and buffers to disk.

Definition at line 2111 of file validation.cpp.

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

◆ FormatStateMessage()

std::string FormatStateMessage ( const CValidationState state)

Convert CValidationState to a human-readable message for logging.

Definition at line 453 of file validation.cpp.

Here is the call graph for this function:
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 3104 of file validation.cpp.

◆ GetBlockFileInfo()

CBlockFileInfo* GetBlockFileInfo ( size_t  n)

Get block file info entry for one block file.

Definition at line 4586 of file validation.cpp.

Here is the caller graph for this function:

◆ GetBlockPosFilename()

fs::path GetBlockPosFilename ( const CDiskBlockPos pos,
const char *  prefix 
)

Translation to a filesystem path.

Definition at line 3720 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 1154 of file validation.cpp.

◆ 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 1338 of file validation.cpp.

Here is the call graph for this function:

◆ GetTransaction()

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

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

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 998 of file validation.cpp.

Here is the call graph for this function:

◆ 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 verification progress (as a fraction between 0.0=genesis and 1.0=current tip).

Definition at line 4745 of file validation.cpp.

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

◆ InitScriptExecutionCache()

void InitScriptExecutionCache ( )

Initializes the script-execution cache.

Definition at line 1349 of file validation.cpp.

Here is the call graph for this function:

◆ InvalidateBlock()

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

Mark a block as invalid.

Definition at line 2776 of file validation.cpp.

Here is the call graph for this function:

◆ IsBlockPruned()

bool IsBlockPruned ( const CBlockIndex pblockindex)
inline

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

Definition at line 498 of file validation.h.

◆ IsInitialBlockDownload()

bool IsInitialBlockDownload ( )

Check whether we are doing an initial block download (synchronizing from disk or network)

Definition at line 1167 of file validation.cpp.

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

◆ IsNullDummyEnabled()

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

Check whether NULLDUMMY (BIP 147) has activated.

Definition at line 3071 of file validation.cpp.

◆ IsWitnessEnabled()

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

Check whether witness commitments are required for block.

Definition at line 3061 of file validation.cpp.

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 4223 of file validation.cpp.

Here is the call graph for this function:

◆ LoadChainTip()

bool LoadChainTip ( const CChainParams chainparams)

Update the chain tip based on database information.

Definition at line 3850 of file validation.cpp.

Here is the call graph for this function:

◆ LoadExternalBlockFile()

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

Import blocks from an external file.

Definition at line 4275 of file validation.cpp.

Here is the call 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 4270 of file validation.cpp.

Here is the call graph for this function:

◆ LoadMempool()

bool LoadMempool ( )

Load the mempool from disk.

Definition at line 4613 of file validation.cpp.

Here is the call graph for this function:

◆ LookupBlockIndex()

CBlockIndex* LookupBlockIndex ( const uint256 hash)
inline

Definition at line 431 of file validation.h.

Here is the caller graph for this function:

◆ OpenBlockFile()

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

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

Definition at line 3711 of file validation.cpp.

Here is the caller graph for this function:

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

Definition at line 2708 of file validation.cpp.

Here is the call 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
True if state.IsValid()

Definition at line 3455 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,
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

Definition at line 3336 of file validation.cpp.

Here is the call graph for this function:

◆ PruneAndFlush()

void PruneAndFlush ( )

Prune block files and flush state to disk.

Definition at line 2119 of file validation.cpp.

Here is the call graph for this function:

◆ PruneBlockFilesManual()

void PruneBlockFilesManual ( int  nManualPruneHeight)

Prune block files up to a given height.

Definition at line 3597 of file validation.cpp.

Here is the call graph for this function:

◆ PruneOneBlockFile()

void PruneOneBlockFile ( const int  fileNumber)

Mark one block file as pruned.

Definition at line 3530 of file validation.cpp.

◆ ReadBlockFromDisk() [1/2]

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

Functions for disk access for blocks.

Definition at line 1068 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 1092 of file validation.cpp.

Here is the call graph for this function:

◆ ReadRawBlockFromDisk() [1/2]

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

Definition at line 1108 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 1143 of file validation.cpp.

Here is the call graph for this function:

◆ ReplayBlocks()

bool ReplayBlocks ( const CChainParams params,
CCoinsView view 
)

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

Definition at line 4074 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 2814 of file validation.cpp.

Here is the call 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 4169 of file validation.cpp.

Here is the call graph for this function:

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

Definition at line 3488 of file validation.cpp.

Here is the call 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 347 of file validation.cpp.

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

◆ ThreadScriptCheck()

void ThreadScriptCheck ( )

Run an instance of the script checking thread.

Definition at line 1679 of file validation.cpp.

Here is the call graph for this function:

◆ UnlinkPrunedFiles()

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

Actually unlink the specified files.

Definition at line 3564 of file validation.cpp.

Here is the call graph for this function:

◆ UnloadBlockIndex()

void UnloadBlockIndex ( )

Unload database information.

Definition at line 4197 of file validation.cpp.

Here is the call graph for this function:

◆ UpdateCoins()

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 1326 of file validation.cpp.

Here is the call graph for this function:

◆ 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 3092 of file validation.cpp.

◆ 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 4593 of file validation.cpp.

Here is the call 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 4605 of file validation.cpp.

Here is the call 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 4599 of file validation.cpp.

Here is the call graph for this function:

Variable Documentation

◆ chainActive

CChain& chainActive

The currently-connected chain of blocks (protected by cs_main).

Definition at line 219 of file validation.cpp.

◆ COINBASE_FLAGS

CScript COINBASE_FLAGS

Constant stuff for coinbase transactions we create:

Definition at line 249 of file validation.cpp.

◆ cs_main

Definition at line 216 of file validation.cpp.

◆ fCheckBlockIndex

bool fCheckBlockIndex

Definition at line 231 of file validation.cpp.

◆ fCheckpointsEnabled

bool fCheckpointsEnabled

Definition at line 232 of file validation.cpp.

◆ feeEstimator

CBlockPolicyEstimator feeEstimator

Definition at line 244 of file validation.cpp.

◆ fEnableReplacement

bool fEnableReplacement

Definition at line 236 of file validation.cpp.

◆ fHavePruned

bool fHavePruned

Pruning-related variables and constants.

True if any block files have ever been pruned.

Definition at line 227 of file validation.cpp.

◆ fImporting

std::atomic_bool fImporting

◆ fIsBareMultisigStd

bool fIsBareMultisigStd

Definition at line 229 of file validation.cpp.

◆ fPruneMode

bool fPruneMode

True if we're running in -prune mode.

Definition at line 228 of file validation.cpp.

◆ fReindex

std::atomic_bool fReindex

◆ fRequireStandard

bool fRequireStandard

Definition at line 230 of file validation.cpp.

◆ g_best_block

uint256 g_best_block

Definition at line 223 of file validation.cpp.

◆ g_best_block_cv

std::condition_variable g_best_block_cv

Definition at line 222 of file validation.cpp.

◆ g_best_block_mutex

Mutex g_best_block_mutex

Definition at line 221 of file validation.cpp.

◆ g_is_mempool_loaded

std::atomic_bool g_is_mempool_loaded

Definition at line 246 of file validation.cpp.

◆ hashAssumeValid

uint256 hashAssumeValid

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

Definition at line 238 of file validation.cpp.

◆ mapBlockIndex

BlockMap& mapBlockIndex

Definition at line 218 of file validation.cpp.

◆ maxTxFee

CAmount maxTxFee

Absolute maximum transaction fee (in satoshis) used by wallet and mempool (rejects high fee in sendrawtransaction)

Definition at line 242 of file validation.cpp.

◆ mempool

CTxMemPool mempool

◆ minRelayTxFee

CFeeRate minRelayTxFee

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

Definition at line 241 of file validation.cpp.

◆ nCoinCacheUsage

size_t nCoinCacheUsage

Definition at line 233 of file validation.cpp.

◆ nLastBlockTx

uint64_t nLastBlockTx

Definition at line 41 of file miner.cpp.

◆ nLastBlockWeight

uint64_t nLastBlockWeight

Definition at line 42 of file miner.cpp.

◆ nMaxTipAge

int64_t nMaxTipAge

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

Definition at line 235 of file validation.cpp.

◆ nMinimumChainWork

arith_uint256 nMinimumChainWork

Minimum work we will assume exists on some valid chain.

Definition at line 239 of file validation.cpp.

◆ nPruneTarget

uint64_t nPruneTarget

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

Definition at line 234 of file validation.cpp.

◆ nScriptCheckThreads

int nScriptCheckThreads

Definition at line 224 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 299 of file validation.cpp.

◆ pcoinsdbview

std::unique_ptr<CCoinsViewDB> pcoinsdbview

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

Definition at line 297 of file validation.cpp.

◆ pcoinsTip

std::unique_ptr<CCoinsViewCache> pcoinsTip

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

Definition at line 298 of file validation.cpp.

◆ pindexBestHeader

CBlockIndex* pindexBestHeader

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

Definition at line 220 of file validation.cpp.

◆ strMessageMagic

const std::string strMessageMagic

Definition at line 251 of file validation.cpp.

◆ versionbitscache

VersionBitsCache versionbitscache

Definition at line 1685 of file validation.cpp.