Dash Core  0.12.2.1
P2P Digital Currency
validation.cpp File Reference
#include "validation.h"
#include "alert.h"
#include "arith_uint256.h"
#include "chainparams.h"
#include "checkpoints.h"
#include "checkqueue.h"
#include "consensus/consensus.h"
#include "consensus/merkle.h"
#include "consensus/validation.h"
#include "hash.h"
#include "init.h"
#include "policy/policy.h"
#include "pow.h"
#include "primitives/block.h"
#include "primitives/transaction.h"
#include "script/script.h"
#include "script/sigcache.h"
#include "script/standard.h"
#include "timedata.h"
#include "tinyformat.h"
#include "txdb.h"
#include "txmempool.h"
#include "ui_interface.h"
#include "undo.h"
#include "util.h"
#include "spork.h"
#include "utilmoneystr.h"
#include "utilstrencodings.h"
#include "validationinterface.h"
#include "versionbits.h"
#include "instantx.h"
#include "masternodeman.h"
#include "masternode-payments.h"
#include <sstream>
#include <boost/algorithm/string/replace.hpp>
#include <boost/filesystem.hpp>
#include <boost/filesystem/fstream.hpp>
#include <boost/lexical_cast.hpp>
#include <boost/math/distributions/poisson.hpp>
#include <boost/thread.hpp>

Go to the source code of this file.

Classes

class  WarningBitsConditionChecker
 
class  CMainCleanup
 

Namespaces

 Consensus
 

Enumerations

enum  FlushStateMode { FLUSH_STATE_NONE, FLUSH_STATE_IF_NEEDED, FLUSH_STATE_PERIODIC, FLUSH_STATE_ALWAYS }
 

Functions

map< uint256, int64_t > mapRejectedBlocks GUARDED_BY (cs_main)
 
static bool IsSuperMajority (int minVersion, const CBlockIndex *pstart, unsigned nRequired, const Consensus::Params &consensusParams)
 
static void CheckBlockIndex (const Consensus::Params &consensusParams)
 
CBlockIndexFindForkInGlobalIndex (const CChain &chain, const CBlockLocator &locator)
 
static bool FlushStateToDisk (CValidationState &state, FlushStateMode mode)
 
bool IsFinalTx (const CTransaction &tx, int nBlockHeight, int64_t nBlockTime)
 
bool CheckFinalTx (const CTransaction &tx, int flags)
 
static std::pair< int, int64_t > CalculateSequenceLocks (const CTransaction &tx, int flags, std::vector< int > *prevHeights, const CBlockIndex &block)
 
static bool EvaluateSequenceLocks (const CBlockIndex &block, std::pair< int, int64_t > lockPair)
 
bool SequenceLocks (const CTransaction &tx, int flags, std::vector< int > *prevHeights, const CBlockIndex &block)
 
bool TestLockPointValidity (const LockPoints *lp)
 
bool CheckSequenceLocks (const CTransaction &tx, int flags, LockPoints *lp, bool useExistingLockPoints)
 
unsigned int GetLegacySigOpCount (const CTransaction &tx)
 
unsigned int GetP2SHSigOpCount (const CTransaction &tx, const CCoinsViewCache &inputs)
 
bool GetUTXOCoins (const COutPoint &outpoint, CCoins &coins)
 
int GetUTXOHeight (const COutPoint &outpoint)
 
int GetUTXOConfirmations (const COutPoint &outpoint)
 
bool CheckTransaction (const CTransaction &tx, CValidationState &state)
 
bool ContextualCheckTransaction (const CTransaction &tx, CValidationState &state, CBlockIndex *const pindexPrev)
 
void LimitMempoolSize (CTxMemPool &pool, size_t limit, unsigned long age)
 
std::string FormatStateMessage (const CValidationState &state)
 
bool AcceptToMemoryPoolWorker (CTxMemPool &pool, CValidationState &state, const CTransaction &tx, bool fLimitFree, bool *pfMissingInputs, bool fOverrideMempoolLimit, bool fRejectAbsurdFee, std::vector< uint256 > &vHashTxnToUncache, bool fDryRun)
 
bool AcceptToMemoryPool (CTxMemPool &pool, CValidationState &state, const CTransaction &tx, bool fLimitFree, bool *pfMissingInputs, bool fOverrideMempoolLimit, bool fRejectAbsurdFee, bool fDryRun)
 
bool GetTimestampIndex (const unsigned int &high, const unsigned int &low, std::vector< uint256 > &hashes)
 
bool GetSpentIndex (CSpentIndexKey &key, CSpentIndexValue &value)
 
bool GetAddressIndex (uint160 addressHash, int type, std::vector< std::pair< CAddressIndexKey, CAmount > > &addressIndex, int start, int end)
 
bool GetAddressUnspent (uint160 addressHash, int type, std::vector< std::pair< CAddressUnspentKey, CAddressUnspentValue > > &unspentOutputs)
 
bool GetTransaction (const uint256 &hash, CTransaction &txOut, const Consensus::Params &consensusParams, uint256 &hashBlock, bool fAllowSlow)
 
bool WriteBlockToDisk (const CBlock &block, CDiskBlockPos &pos, const CMessageHeader::MessageStartChars &messageStart)
 
bool ReadBlockFromDisk (CBlock &block, const CDiskBlockPos &pos, const Consensus::Params &consensusParams)
 
bool ReadBlockFromDisk (CBlock &block, const CBlockIndex *pindex, const Consensus::Params &consensusParams)
 
double ConvertBitsToDouble (unsigned int nBits)
 
CAmount GetBlockSubsidy (int nPrevBits, int nPrevHeight, const Consensus::Params &consensusParams, bool fSuperblockPartOnly)
 
CAmount GetMasternodePayment (int nHeight, CAmount blockValue)
 
bool IsInitialBlockDownload ()
 
void CheckForkWarningConditions ()
 
void CheckForkWarningConditionsOnNewFork (CBlockIndex *pindexNewForkTip)
 
static void InvalidChainFound (CBlockIndex *pindexNew)
 
static void InvalidBlockFound (CBlockIndex *pindex, const CValidationState &state)
 
void UpdateCoins (const CTransaction &tx, CValidationState &state, CCoinsViewCache &inputs, CTxUndo &txundo, int nHeight)
 
void UpdateCoins (const CTransaction &tx, CValidationState &state, CCoinsViewCache &inputs, int nHeight)
 
int GetSpendHeight (const CCoinsViewCache &inputs)
 
bool Consensus::CheckTxInputs (const CTransaction &tx, CValidationState &state, const CCoinsViewCache &inputs, int nSpendHeight)
 
bool CheckInputs (const CTransaction &tx, CValidationState &state, const CCoinsViewCache &inputs, bool fScriptChecks, unsigned int flags, bool cacheStore, std::vector< CScriptCheck > *pvChecks)
 
static bool ApplyTxInUndo (const CTxInUndo &undo, CCoinsViewCache &view, const COutPoint &out)
 
bool DisconnectBlock (const CBlock &block, CValidationState &state, const CBlockIndex *pindex, CCoinsViewCache &view, bool *pfClean)
 
static void FlushBlockFile (bool fFinalize=false)
 
bool FindUndoPos (CValidationState &state, int nFile, CDiskBlockPos &pos, unsigned int nAddSize)
 
void ThreadScriptCheck ()
 
int32_t ComputeBlockVersion (const CBlockIndex *pindexPrev, const Consensus::Params &params, bool fAssumeMasternodeIsUpgraded)
 
bool GetBlockHash (uint256 &hashRet, int nBlockHeight)
 
bool ConnectBlock (const CBlock &block, CValidationState &state, CBlockIndex *pindex, CCoinsViewCache &view, bool fJustCheck)
 
void FlushStateToDisk ()
 
void PruneAndFlush ()
 
static void UpdateTip (CBlockIndex *pindexNew)
 
static bool DisconnectTip (CValidationState &state, const Consensus::Params &consensusParams)
 
static bool ConnectTip (CValidationState &state, const CChainParams &chainparams, CBlockIndex *pindexNew, const CBlock *pblock)
 
bool DisconnectBlocks (int blocks)
 
void ReprocessBlocks (int nBlocks)
 
static CBlockIndexFindMostWorkChain ()
 
static void PruneBlockIndexCandidates ()
 
static bool ActivateBestChainStep (CValidationState &state, const CChainParams &chainparams, CBlockIndex *pindexMostWork, const CBlock *pblock, bool &fInvalidFound)
 
static void NotifyHeaderTip ()
 
bool ActivateBestChain (CValidationState &state, const CChainParams &chainparams, const CBlock *pblock)
 
bool InvalidateBlock (CValidationState &state, const Consensus::Params &consensusParams, CBlockIndex *pindex)
 
bool ReconsiderBlock (CValidationState &state, CBlockIndex *pindex)
 
CBlockIndexAddToBlockIndex (const CBlockHeader &block)
 
bool ReceivedBlockTransactions (const CBlock &block, CValidationState &state, CBlockIndex *pindexNew, const CDiskBlockPos &pos)
 
bool FindBlockPos (CValidationState &state, CDiskBlockPos &pos, unsigned int nAddSize, unsigned int nHeight, uint64_t nTime, bool fKnown=false)
 
bool CheckBlockHeader (const CBlockHeader &block, CValidationState &state, bool fCheckPOW)
 
bool CheckBlock (const CBlock &block, CValidationState &state, bool fCheckPOW, bool fCheckMerkleRoot)
 
static bool CheckIndexAgainstCheckpoint (const CBlockIndex *pindexPrev, CValidationState &state, const CChainParams &chainparams, const uint256 &hash)
 
bool ContextualCheckBlockHeader (const CBlockHeader &block, CValidationState &state, CBlockIndex *const pindexPrev)
 
bool ContextualCheckBlock (const CBlock &block, CValidationState &state, CBlockIndex *const pindexPrev)
 
static bool AcceptBlockHeader (const CBlockHeader &block, CValidationState &state, const CChainParams &chainparams, CBlockIndex **ppindex)
 
bool ProcessNewBlockHeaders (const std::vector< CBlockHeader > &headers, CValidationState &state, const CChainParams &chainparams, CBlockIndex **ppindex)
 
static bool AcceptBlock (const CBlock &block, CValidationState &state, const CChainParams &chainparams, CBlockIndex **ppindex, bool fRequested, const CDiskBlockPos *dbp, bool *fNewBlock)
 
bool ProcessNewBlock (const CChainParams &chainparams, const CBlock *pblock, bool fForceProcessing, const CDiskBlockPos *dbp, bool *fNewBlock)
 
bool TestBlockValidity (CValidationState &state, const CChainParams &chainparams, const CBlock &block, CBlockIndex *pindexPrev, bool fCheckPOW, bool fCheckMerkleRoot)
 
uint64_t CalculateCurrentUsage ()
 
void PruneOneBlockFile (const int fileNumber)
 
void UnlinkPrunedFiles (std::set< int > &setFilesToPrune)
 
void FindFilesToPrune (std::set< int > &setFilesToPrune, uint64_t nPruneAfterHeight)
 
bool CheckDiskSpace (uint64_t nAdditionalBytes)
 
FILE * OpenDiskFile (const CDiskBlockPos &pos, const char *prefix, bool fReadOnly)
 
FILE * OpenBlockFile (const CDiskBlockPos &pos, bool fReadOnly)
 
FILE * OpenUndoFile (const CDiskBlockPos &pos, bool fReadOnly)
 
boost::filesystem::path GetBlockPosFilename (const CDiskBlockPos &pos, const char *prefix)
 
CBlockIndexInsertBlockIndex (uint256 hash)
 
static bool LoadBlockIndexDB ()
 
void UnloadBlockIndex ()
 
bool LoadBlockIndex ()
 
bool InitBlockIndex (const CChainParams &chainparams)
 
bool LoadExternalBlockFile (const CChainParams &chainparams, FILE *fileIn, CDiskBlockPos *dbp)
 
std::string GetWarnings (const std::string &strFor)
 
ThresholdState VersionBitsTipState (const Consensus::Params &params, Consensus::DeploymentPos pos)
 

Variables

CCriticalSection cs_main
 
BlockMap mapBlockIndex
 
CChain chainActive
 
CBlockIndexpindexBestHeader = NULL
 
CWaitableCriticalSection csBestBlock
 
CConditionVariable cvBlockChange
 
int nScriptCheckThreads = 0
 
bool fImporting = false
 
bool fReindex = false
 
bool fTxIndex = true
 
bool fAddressIndex = false
 
bool fTimestampIndex = false
 
bool fSpentIndex = false
 
bool fHavePruned = false
 
bool fPruneMode = false
 
bool fIsBareMultisigStd = DEFAULT_PERMIT_BAREMULTISIG
 
bool fRequireStandard = true
 
unsigned int nBytesPerSigOp = DEFAULT_BYTES_PER_SIGOP
 
bool fCheckBlockIndex = false
 
bool fCheckpointsEnabled = DEFAULT_CHECKPOINTS_ENABLED
 
size_t nCoinCacheUsage = 5000 * 300
 
uint64_t nPruneTarget = 0
 
bool fAlerts = DEFAULT_ALERTS
 
bool fEnableReplacement = DEFAULT_ENABLE_REPLACEMENT
 
std::atomic< bool > fDIP0001WasLockedIn {false}
 
std::atomic< bool > fDIP0001ActiveAtTip {false}
 
uint256 hashAssumeValid
 
CFeeRate minRelayTxFee = CFeeRate(DEFAULT_LEGACY_MIN_RELAY_TX_FEE)
 
CTxMemPool mempool (::minRelayTxFee)
 
CScript COINBASE_FLAGS
 
const string strMessageMagic = "DarkCoin Signed Message:\n"
 
CCoinsViewCachepcoinsTip = NULL
 
CBlockTreeDBpblocktree = NULL
 
bool fLargeWorkForkFound = false
 
bool fLargeWorkInvalidChainFound = false
 
CBlockIndexpindexBestForkTip = NULL
 
CBlockIndexpindexBestForkBase = NULL
 
static CCheckQueue< CScriptCheckscriptcheckqueue (128)
 
VersionBitsCache versionbitscache
 
static ThresholdConditionCache warningcache [VERSIONBITS_NUM_BITS]
 
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 nTimeReadFromDisk = 0
 
static int64_t nTimeConnectTotal = 0
 
static int64_t nTimeFlush = 0
 
static int64_t nTimeChainState = 0
 
static int64_t nTimePostConnect = 0
 
class CMainCleanup instance_of_cmaincleanup
 

Enumeration Type Documentation

◆ FlushStateMode

Enumerator
FLUSH_STATE_NONE 
FLUSH_STATE_IF_NEEDED 
FLUSH_STATE_PERIODIC 
FLUSH_STATE_ALWAYS 

Definition at line 190 of file validation.cpp.

Function Documentation

◆ AcceptBlock()

static bool AcceptBlock ( const CBlock block,
CValidationState state,
const CChainParams chainparams,
CBlockIndex **  ppindex,
bool  fRequested,
const CDiskBlockPos dbp,
bool *  fNewBlock 
)
static

Store block on disk. If dbp is non-NULL, the file is known to already reside on disk

Definition at line 3400 of file validation.cpp.

Referenced by LoadExternalBlockFile(), and ProcessNewBlock().

◆ AcceptBlockHeader()

static bool AcceptBlockHeader ( const CBlockHeader block,
CValidationState state,
const CChainParams chainparams,
CBlockIndex **  ppindex 
)
static

Definition at line 3330 of file validation.cpp.

Referenced by AcceptBlock(), and ProcessNewBlockHeaders().

◆ AcceptToMemoryPool()

bool AcceptToMemoryPool ( CTxMemPool pool,
CValidationState state,
const CTransaction tx,
bool  fLimitFree,
bool *  pfMissingInputs,
bool  fOverrideMempoolLimit = false,
bool  fRejectAbsurdFee = false,
bool  fDryRun = false 
)

◆ AcceptToMemoryPoolWorker()

bool AcceptToMemoryPoolWorker ( CTxMemPool pool,
CValidationState state,
const CTransaction tx,
bool  fLimitFree,
bool *  pfMissingInputs,
bool  fOverrideMempoolLimit,
bool  fRejectAbsurdFee,
std::vector< uint256 > &  vHashTxnToUncache,
bool  fDryRun 
)

Definition at line 549 of file validation.cpp.

Referenced by AcceptToMemoryPool().

◆ ActivateBestChain()

bool ActivateBestChain ( CValidationState state,
const CChainParams chainparams,
const CBlock pblock 
)

Make the best chain active, in multiple steps. The result is either failure or an activated best chain. pblock is either NULL or a pointer to a block that is already loaded (to avoid loading it again from disk).

Definition at line 2808 of file validation.cpp.

Referenced by InitBlockIndex(), invalidateblock(), LoadExternalBlockFile(), ProcessNewBlock(), reconsiderblock(), ReprocessBlocks(), and ThreadImport().

◆ ActivateBestChainStep()

static bool ActivateBestChainStep ( CValidationState state,
const CChainParams chainparams,
CBlockIndex pindexMostWork,
const CBlock pblock,
bool &  fInvalidFound 
)
static

Try to make some progress towards making pindexMostWork the active block. pblock is either NULL or a pointer to a CBlock corresponding to pindexMostWork.

Definition at line 2709 of file validation.cpp.

Referenced by ActivateBestChain().

◆ AddToBlockIndex()

CBlockIndex* AddToBlockIndex ( const CBlockHeader block)

Definition at line 2936 of file validation.cpp.

Referenced by AcceptBlockHeader(), and InitBlockIndex().

◆ ApplyTxInUndo()

static bool ApplyTxInUndo ( const CTxInUndo undo,
CCoinsViewCache view,
const COutPoint out 
)
static

Apply the undo operation of a CTxInUndo to the given chain state.

Parameters
undoThe undo object.
viewThe coins view to which to apply the changes.
outThe out point that corresponds to the tx input.
Returns
True on success.

Definition at line 1670 of file validation.cpp.

Referenced by DisconnectBlock().

◆ CalculateCurrentUsage()

uint64_t CalculateCurrentUsage ( )

BLOCK PRUNING CODE

Definition at line 3542 of file validation.cpp.

Referenced by FindFilesToPrune().

◆ CalculateSequenceLocks()

static std::pair<int, int64_t> CalculateSequenceLocks ( const CTransaction tx,
int  flags,
std::vector< int > *  prevHeights,
const CBlockIndex block 
)
static

Calculates the block height and previous block's median time past at which the transaction will be considered final in the context of BIP 68. Also removes from the vector of input heights any entries which did not correspond to sequence locked inputs as they do not affect the calculation.

Definition at line 251 of file validation.cpp.

Referenced by CheckSequenceLocks(), and SequenceLocks().

◆ CheckBlock()

bool CheckBlock ( const CBlock block,
CValidationState state,
bool  fCheckPOW,
bool  fCheckMerkleRoot 
)

Definition at line 3119 of file validation.cpp.

Referenced by AcceptBlock(), ConnectBlock(), TestBlockValidity(), and CVerifyDB::VerifyDB().

◆ CheckBlockHeader()

bool CheckBlockHeader ( const CBlockHeader block,
CValidationState state,
bool  fCheckPOW = true 
)

Context-independent validity checks

Definition at line 3104 of file validation.cpp.

Referenced by AcceptBlockHeader(), and CheckBlock().

◆ CheckBlockIndex()

static void CheckBlockIndex ( const Consensus::Params consensusParams)
static

Definition at line 4124 of file validation.cpp.

Referenced by AcceptBlockHeader(), ActivateBestChain(), and ProcessNewBlock().

◆ CheckDiskSpace()

bool CheckDiskSpace ( uint64_t  nAdditionalBytes = 0)

Check whether enough disk space is available for an incoming block

Definition at line 3642 of file validation.cpp.

Referenced by AppInit2(), FindBlockPos(), FindUndoPos(), FlushStateToDisk(), and CPrivateSendClient::SendDenominate().

◆ CheckFinalTx()

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

◆ CheckForkWarningConditions()

void CheckForkWarningConditions ( )

◆ CheckForkWarningConditionsOnNewFork()

void CheckForkWarningConditionsOnNewFork ( CBlockIndex pindexNewForkTip)

Definition at line 1368 of file validation.cpp.

Referenced by ActivateBestChainStep().

◆ CheckIndexAgainstCheckpoint()

static bool CheckIndexAgainstCheckpoint ( const CBlockIndex pindexPrev,
CValidationState state,
const CChainParams chainparams,
const uint256 hash 
)
static

Definition at line 3218 of file validation.cpp.

Referenced by AcceptBlockHeader(), and TestBlockValidity().

◆ CheckInputs()

bool CheckInputs ( const CTransaction tx,
CValidationState state,
const CCoinsViewCache view,
bool  fScriptChecks,
unsigned int  flags,
bool  cacheStore,
std::vector< CScriptCheck > *  pvChecks = NULL 
)

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 NULL, script checks are pushed onto it instead of being performed inline.

Definition at line 1528 of file validation.cpp.

Referenced by AcceptToMemoryPoolWorker(), CTxMemPool::check(), and ConnectBlock().

◆ CheckSequenceLocks()

bool CheckSequenceLocks ( const CTransaction tx,
int  flags,
LockPoints lp = NULL,
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 346 of file validation.cpp.

Referenced by AcceptToMemoryPoolWorker(), and CTxMemPool::removeForReorg().

◆ CheckTransaction()

bool CheckTransaction ( const CTransaction tx,
CValidationState state 
)

Context-independent validity checks

Definition at line 470 of file validation.cpp.

Referenced by AcceptToMemoryPoolWorker(), CheckBlock(), and ReadKeyValue().

◆ ComputeBlockVersion()

int32_t ComputeBlockVersion ( const CBlockIndex pindexPrev,
const Consensus::Params params,
bool  fAssumeMasternodeIsUpgraded = false 
)

Determine what nVersion a new block should use.

Definition at line 1878 of file validation.cpp.

Referenced by WarningBitsConditionChecker::Condition(), CreateNewBlock(), and UpdateTip().

◆ ConnectBlock()

bool ConnectBlock ( const CBlock block,
CValidationState state,
CBlockIndex pindex,
CCoinsViewCache coins,
bool  fJustCheck = false 
)

Apply the effects of this block (with given index) on the UTXO set represented by coins

Definition at line 1956 of file validation.cpp.

Referenced by ConnectTip(), TestBlockValidity(), and CVerifyDB::VerifyDB().

◆ ConnectTip()

static bool ConnectTip ( CValidationState state,
const CChainParams chainparams,
CBlockIndex pindexNew,
const CBlock pblock 
)
static

Connect a new block to chainActive. pblock is either NULL or a pointer to a CBlock corresponding to pindexNew, to bypass loading it again from disk.

Definition at line 2535 of file validation.cpp.

Referenced by ActivateBestChainStep().

◆ ContextualCheckBlock()

bool ContextualCheckBlock ( const CBlock block,
CValidationState state,
CBlockIndex *const  pindexPrev 
)

Definition at line 3275 of file validation.cpp.

Referenced by AcceptBlock(), and TestBlockValidity().

◆ ContextualCheckBlockHeader()

bool ContextualCheckBlockHeader ( const CBlockHeader block,
CValidationState state,
CBlockIndex pindexPrev 
)

Context-dependent validity checks

Definition at line 3232 of file validation.cpp.

Referenced by AcceptBlockHeader(), and TestBlockValidity().

◆ ContextualCheckTransaction()

bool ContextualCheckTransaction ( const CTransaction tx,
CValidationState state,
CBlockIndex *const  pindexPrev 
)

Definition at line 518 of file validation.cpp.

Referenced by AcceptToMemoryPoolWorker().

◆ ConvertBitsToDouble()

double ConvertBitsToDouble ( unsigned int  nBits)

Definition at line 1205 of file validation.cpp.

Referenced by ContextualCheckBlockHeader(), and GetBlockSubsidy().

◆ DisconnectBlock()

bool DisconnectBlock ( const CBlock block,
CValidationState state,
const CBlockIndex pindex,
CCoinsViewCache coins,
bool *  pfClean = NULL 
)

Functions for validating blocks and updating the block tree Undo the effects of this block (with given index) on the UTXO set represented by coins. In case pfClean is provided, operation will try to be tolerant about errors, and *pfClean will be true if no problems were found. Otherwise, the return value will be false in case of problems. Note that in any case, coins may be modified.

Definition at line 1696 of file validation.cpp.

Referenced by DisconnectTip(), and CVerifyDB::VerifyDB().

◆ DisconnectBlocks()

bool DisconnectBlocks ( int  blocks)

Reprocess a number of blocks to try and get on the correct chain again

Definition at line 2591 of file validation.cpp.

Referenced by ReprocessBlocks().

◆ DisconnectTip()

static bool DisconnectTip ( CValidationState state,
const Consensus::Params consensusParams 
)
static

Disconnect chainActive's tip. You probably want to call mempool.removeForReorg and manually re-limit mempool size after this, with cs_main held.

Definition at line 2477 of file validation.cpp.

Referenced by ActivateBestChainStep(), DisconnectBlocks(), and InvalidateBlock().

◆ EvaluateSequenceLocks()

static bool EvaluateSequenceLocks ( const CBlockIndex block,
std::pair< int, int64_t >  lockPair 
)
static

Definition at line 313 of file validation.cpp.

Referenced by CheckSequenceLocks(), and SequenceLocks().

◆ FindBlockPos()

bool FindBlockPos ( CValidationState state,
CDiskBlockPos pos,
unsigned int  nAddSize,
unsigned int  nHeight,
uint64_t  nTime,
bool  fKnown = false 
)

Definition at line 3016 of file validation.cpp.

Referenced by AcceptBlock(), and InitBlockIndex().

◆ FindFilesToPrune()

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

Referenced by FlushStateToDisk().

◆ FindForkInGlobalIndex()

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

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

Definition at line 172 of file validation.cpp.

Referenced by AppInit2(), and ProcessMessage().

◆ FindMostWorkChain()

static CBlockIndex* FindMostWorkChain ( )
static

Return the tip of the chain with the most work in it, that isn't known to be invalid (it's however far from certain to be valid).

Definition at line 2639 of file validation.cpp.

Referenced by ActivateBestChain().

◆ FindUndoPos()

bool FindUndoPos ( CValidationState state,
int  nFile,
CDiskBlockPos pos,
unsigned int  nAddSize 
)

Definition at line 3073 of file validation.cpp.

Referenced by ConnectBlock().

◆ FlushBlockFile()

static void FlushBlockFile ( bool  fFinalize = false)
static

Definition at line 1843 of file validation.cpp.

Referenced by FindBlockPos(), and FlushStateToDisk().

◆ FlushStateToDisk() [1/2]

static bool FlushStateToDisk ( CValidationState state,
FlushStateMode  mode 
)
static

Update the on-disk chain state. The caches and indexes are flushed depending on the mode we're called with if they're too large, if it's been a while since the last write, or always and in all cases if we're in prune mode and are deleting files.

Definition at line 2311 of file validation.cpp.

Referenced by AcceptBlock(), AcceptToMemoryPool(), ActivateBestChain(), ConnectTip(), DisconnectTip(), FlushStateToDisk(), gettxoutsetinfo(), InitBlockIndex(), PrepareShutdown(), and PruneAndFlush().

◆ FlushStateToDisk() [2/2]

void FlushStateToDisk ( )

Flush all state, indexes and buffers to disk.

Definition at line 2408 of file validation.cpp.

◆ FormatStateMessage()

std::string FormatStateMessage ( const CValidationState state)

Convert CValidationState to a human-readable message for logging

Definition at line 541 of file validation.cpp.

Referenced by AcceptToMemoryPoolWorker(), CheckBlock(), ConnectBlock(), CreateNewBlock(), and ProcessMessage().

◆ GetAddressIndex()

bool GetAddressIndex ( uint160  addressHash,
int  type,
std::vector< std::pair< CAddressIndexKey, CAmount > > &  addressIndex,
int  start,
int  end 
)

Definition at line 1055 of file validation.cpp.

Referenced by getaddressbalance(), getaddressdeltas(), and getaddresstxids().

◆ GetAddressUnspent()

bool GetAddressUnspent ( uint160  addressHash,
int  type,
std::vector< std::pair< CAddressUnspentKey, CAddressUnspentValue > > &  unspentOutputs 
)

Definition at line 1067 of file validation.cpp.

Referenced by getaddressutxos().

◆ GetBlockHash()

bool GetBlockHash ( uint256 hashRet,
int  nBlockHeight = -1 
)

◆ GetBlockPosFilename()

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

Translation to a filesystem path

Definition at line 3684 of file validation.cpp.

Referenced by OpenDiskFile(), ThreadImport(), and UnlinkPrunedFiles().

◆ GetBlockSubsidy()

CAmount GetBlockSubsidy ( int  nPrevBits,
int  nPrevHeight,
const Consensus::Params consensusParams,
bool  fSuperblockPartOnly 
)

Definition at line 1230 of file validation.cpp.

Referenced by ConnectBlock(), CreateNewBlock(), and CSuperblock::GetPaymentsLimit().

◆ GetLegacySigOpCount()

unsigned int GetLegacySigOpCount ( const CTransaction tx)

Count ECDSA signature operations the old-fashioned (pre-0.6) way

Returns
number of sigops this transaction's outputs will produce when spent
See also
CTransaction::FetchInputs

Definition at line 417 of file validation.cpp.

Referenced by AcceptToMemoryPoolWorker(), CheckBlock(), ConnectBlock(), ContextualCheckBlock(), and CreateNewBlock().

◆ GetMasternodePayment()

CAmount GetMasternodePayment ( int  nHeight,
CAmount  blockValue 
)

◆ GetP2SHSigOpCount()

unsigned int GetP2SHSigOpCount ( const CTransaction tx,
const CCoinsViewCache mapInputs 
)

Count ECDSA signature operations in pay-to-script-hash inputs.

Parameters
[in]mapInputsMap of previous transactions that have outputs we're spending
Returns
maximum number of sigops required to validate this transaction's inputs
See also
CTransaction::FetchInputs

Definition at line 431 of file validation.cpp.

Referenced by AcceptToMemoryPoolWorker(), and ConnectBlock().

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

Referenced by CheckInputs().

◆ GetSpentIndex()

bool GetSpentIndex ( CSpentIndexKey key,
CSpentIndexValue value 
)

Definition at line 1041 of file validation.cpp.

Referenced by getspentinfo(), and TxToJSON().

◆ GetTimestampIndex()

bool GetTimestampIndex ( const unsigned int &  high,
const unsigned int &  low,
std::vector< uint256 > &  hashes 
)

Definition at line 1030 of file validation.cpp.

Referenced by getblockhashes().

◆ GetTransaction()

bool GetTransaction ( const uint256 hash,
CTransaction txOut,
const Consensus::Params consensusParams,
uint256 hashBlock,
bool  fAllowSlow 
)

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

Definition at line 1080 of file validation.cpp.

Referenced by CMasternodeBroadcast::CheckOutpoint(), getrawtransaction(), gettxoutproof(), CGovernanceObject::IsCollateralValid(), CMasternode::IsInputAssociatedWithPubkey(), CInstantSend::ResolveConflicts(), and rest_tx().

◆ GetUTXOCoins()

◆ GetUTXOConfirmations()

int GetUTXOConfirmations ( const COutPoint outpoint)

◆ GetUTXOHeight()

int GetUTXOHeight ( const COutPoint outpoint)

◆ GetWarnings()

std::string GetWarnings ( const std::string &  strFor)

Format a string that describes several potential problems detected by the core. strFor can have three values:

  • "rpc": get critical warnings, which should put the client in safe mode if non-empty
  • "statusbar": get all warnings
  • "gui": get all warnings, translated (where possible) for GUI This function only returns the highest priority warning of the set selected by strFor.

Definition at line 4313 of file validation.cpp.

Referenced by getinfo(), getmininginfo(), getnetworkinfo(), ClientModel::getStatusBarWarnings(), and OnRPCPreCommand().

◆ GUARDED_BY()

map<uint256, int64_t> mapRejectedBlocks GUARDED_BY ( cs_main  )

◆ InitBlockIndex()

bool InitBlockIndex ( const CChainParams chainparams)

Initialize a new block tree database + block data on disk

Definition at line 3956 of file validation.cpp.

Referenced by AppInit2(), and ThreadImport().

◆ InsertBlockIndex()

CBlockIndex* InsertBlockIndex ( uint256  hash)

Create a new block index entry for a given block hash

Definition at line 3689 of file validation.cpp.

Referenced by CBlockTreeDB::LoadBlockIndexGuts().

◆ InvalidateBlock()

bool InvalidateBlock ( CValidationState state,
const Consensus::Params consensusParams,
CBlockIndex pindex 
)

Mark a block as invalid.

Definition at line 2863 of file validation.cpp.

Referenced by invalidateblock().

◆ InvalidBlockFound()

static void InvalidBlockFound ( CBlockIndex pindex,
const CValidationState state 
)
static

Definition at line 1418 of file validation.cpp.

Referenced by ConnectTip().

◆ InvalidChainFound()

static void InvalidChainFound ( CBlockIndex pindexNew)
static

Definition at line 1401 of file validation.cpp.

Referenced by ActivateBestChainStep(), InvalidateBlock(), and InvalidBlockFound().

◆ IsFinalTx()

bool IsFinalTx ( const CTransaction tx,
int  nBlockHeight,
int64_t  nBlockTime 
)

Check if transaction is final and can be included in a block with the specified height and time. Consensus critical.

Definition at line 200 of file validation.cpp.

Referenced by CheckFinalTx(), ContextualCheckBlock(), and CreateNewBlock().

◆ IsInitialBlockDownload()

◆ IsSuperMajority()

static bool IsSuperMajority ( int  minVersion,
const CBlockIndex pstart,
unsigned  nRequired,
const Consensus::Params consensusParams 
)
static

Returns true if there are nRequired or more blocks of minVersion or above in the last Consensus::Params::nMajorityWindow blocks, starting at pstart and going backwards.

Definition at line 3471 of file validation.cpp.

Referenced by ConnectBlock(), ContextualCheckBlock(), and ContextualCheckBlockHeader().

◆ LimitMempoolSize()

void LimitMempoolSize ( CTxMemPool pool,
size_t  limit,
unsigned long  age 
)

◆ LoadBlockIndex()

bool LoadBlockIndex ( )

Load the block tree and coins database from disk

Definition at line 3948 of file validation.cpp.

Referenced by AppInit2().

◆ LoadBlockIndexDB()

static bool LoadBlockIndexDB ( )
static

Definition at line 3709 of file validation.cpp.

Referenced by LoadBlockIndex().

◆ LoadExternalBlockFile()

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

Import blocks from an external file

Definition at line 4008 of file validation.cpp.

Referenced by ThreadImport().

◆ NotifyHeaderTip()

static void NotifyHeaderTip ( )
static

Definition at line 2781 of file validation.cpp.

Referenced by LoadExternalBlockFile(), ProcessNewBlock(), and ProcessNewBlockHeaders().

◆ OpenBlockFile()

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

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

Definition at line 3676 of file validation.cpp.

Referenced by FindBlockPos(), FlushBlockFile(), GetTransaction(), LoadBlockIndexDB(), ReadBlockFromDisk(), ThreadImport(), and WriteBlockToDisk().

◆ OpenDiskFile()

FILE* OpenDiskFile ( const CDiskBlockPos pos,
const char *  prefix,
bool  fReadOnly 
)

Definition at line 3653 of file validation.cpp.

Referenced by OpenBlockFile(), and OpenUndoFile().

◆ OpenUndoFile()

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

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

Definition at line 3680 of file validation.cpp.

Referenced by FindUndoPos(), and FlushBlockFile().

◆ ProcessNewBlock()

bool ProcessNewBlock ( const CChainParams chainparams,
const CBlock pblock,
bool  fForceProcessing,
const CDiskBlockPos dbp,
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.

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]dbpThe already known disk position of pblock, or NULL if not yet stored.
[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 3484 of file validation.cpp.

Referenced by generate(), ProcessBlockFound(), ProcessMessage(), and submitblock().

◆ ProcessNewBlockHeaders()

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

Process incoming block headers.

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

Referenced by ProcessMessage().

◆ PruneAndFlush()

void PruneAndFlush ( )

Prune block files and flush state to disk.

Definition at line 2413 of file validation.cpp.

Referenced by AppInit2().

◆ PruneBlockIndexCandidates()

static void PruneBlockIndexCandidates ( )
static

Delete all entries in setBlockIndexCandidates that are worse than the current tip.

Definition at line 2694 of file validation.cpp.

Referenced by ActivateBestChainStep(), and LoadBlockIndexDB().

◆ PruneOneBlockFile()

void PruneOneBlockFile ( const int  fileNumber)

Definition at line 3552 of file validation.cpp.

Referenced by FindFilesToPrune().

◆ ReadBlockFromDisk() [1/2]

◆ ReadBlockFromDisk() [2/2]

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

Definition at line 1195 of file validation.cpp.

◆ ReceivedBlockTransactions()

bool ReceivedBlockTransactions ( const CBlock block,
CValidationState state,
CBlockIndex pindexNew,
const CDiskBlockPos pos 
)

Mark a block as having its data received and checked (up to BLOCK_VALID_TRANSACTIONS).

Definition at line 2971 of file validation.cpp.

Referenced by AcceptBlock(), and InitBlockIndex().

◆ ReconsiderBlock()

bool ReconsiderBlock ( CValidationState state,
CBlockIndex pindex 
)

Remove invalidity status from a block and its descendants.

Definition at line 2903 of file validation.cpp.

Referenced by reconsiderblock(), and ReprocessBlocks().

◆ ReprocessBlocks()

void ReprocessBlocks ( int  nBlocks)

Definition at line 2608 of file validation.cpp.

Referenced by CSporkManager::ExecuteSpork().

◆ SequenceLocks()

bool SequenceLocks ( const CTransaction tx,
int  flags,
std::vector< int > *  prevHeights,
const CBlockIndex block 
)

Check if transaction is final per BIP 68 sequence numbers and can be included in a block. Consensus critical. Takes as input a list of heights at which tx's inputs (in order) confirmed.

Definition at line 323 of file validation.cpp.

Referenced by ConnectBlock().

◆ 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, with cs_main held)

Definition at line 3511 of file validation.cpp.

Referenced by CreateNewBlock(), and getblocktemplate().

◆ TestLockPointValidity()

bool TestLockPointValidity ( const LockPoints lp)

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

Definition at line 328 of file validation.cpp.

Referenced by CTxMemPool::removeForReorg().

◆ ThreadScriptCheck()

void ThreadScriptCheck ( )

Run an instance of the script checking thread

Definition at line 1870 of file validation.cpp.

Referenced by AppInit2().

◆ UnlinkPrunedFiles()

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

Actually unlink the specified files

Definition at line 3584 of file validation.cpp.

Referenced by FlushStateToDisk().

◆ UnloadBlockIndex()

void UnloadBlockIndex ( )

Unload database information

Definition at line 3922 of file validation.cpp.

Referenced by AppInit2().

◆ UpdateCoins() [1/2]

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

Definition at line 1427 of file validation.cpp.

Referenced by CTxMemPool::check(), ConnectBlock(), and UpdateCoins().

◆ UpdateCoins() [2/2]

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

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

Definition at line 1461 of file validation.cpp.

◆ UpdateTip()

static void UpdateTip ( CBlockIndex pindexNew)
static

Update chainActive and related internal data structures.

Definition at line 2420 of file validation.cpp.

Referenced by ConnectTip(), and DisconnectTip().

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

Referenced by AcceptToMemoryPoolWorker(), and BIP9SoftForkDesc().

◆ WriteBlockToDisk()

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

Functions for disk access for blocks

Definition at line 1150 of file validation.cpp.

Referenced by AcceptBlock(), and InitBlockIndex().

Variable Documentation

◆ chainActive

CChain chainActive

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

Definition at line 65 of file validation.cpp.

Referenced by AcceptBlock(), AcceptToMemoryPoolWorker(), ActivateBestChain(), ActivateBestChainStep(), AlreadyHave(), AppInit2(), BitcoinMiner(), blockheaderToJSON(), blockToJSON(), CMasternode::Check(), CMasternodePing::CheckAndUpdate(), CheckBlockIndex(), CheckFinalTx(), CheckForkWarningConditions(), CheckForkWarningConditionsOnNewFork(), CMasternodeBroadcast::CheckOutpoint(), CheckSequenceLocks(), CMasternodePing::CMasternodePing(), ConnectTip(), CreateNewBlock(), CWallet::CreateTransaction(), DisconnectTip(), dumpwallet(), FindFilesToPrune(), FindMostWorkChain(), FlushStateToDisk(), TransactionDesc::FormatTxStatus(), generate(), getbestblockhash(), getblockchaininfo(), getblockcount(), getblockhash(), GetBlockHash(), getblockheaders(), getblocktemplate(), getchaintips(), CMerkleTx::GetDepthInMainChain(), GetDifficulty(), getgovernanceinfo(), getinfo(), CWallet::GetKeyBirthTimes(), ClientModel::getLastBlockDate(), getmininginfo(), GetNetworkHashPS(), ClientModel::getNumBlocks(), GetTransaction(), gettxoutproof(), GetUTXOConfirmations(), ClientModel::getVerificationProgress(), importaddress(), importelectrumwallet(), importprivkey(), importpubkey(), importwallet(), InitBlockIndex(), CDSNotificationInterface::InitializeCurrentBlockTip(), InvalidateBlock(), InvalidChainFound(), CGovernanceObject::IsCollateralValid(), IsInitialBlockDownload(), CTxLockRequest::IsValid(), listsinceblock(), LoadBlockIndexDB(), CActiveMasternode::ManageStateLocal(), CWallet::MarkConflicted(), masternode(), masternodelist(), mempoolToJSON(), WalletModel::pollBalanceChanged(), ProcessBlockFound(), ProcessGetData(), ProcessMessage(), CSporkManager::ProcessSpork(), PruneBlockIndexCandidates(), ReceivedBlockTransactions(), ReconsiderBlock(), CMasternodePayments::RequestLowDataPaymentBlocks(), rest_getutxos(), rest_headers(), CWallet::ScanForWalletTransactions(), SendMessages(), CMerkleTx::SetMerkleBranch(), TransactionRecord::statusUpdateNeeded(), TestBlockValidity(), TestLockPointValidity(), TxToJSON(), UnloadBlockIndex(), TransactionRecord::updateStatus(), UpdateTip(), CVerifyDB::VerifyDB(), verifytxoutproof(), and VersionBitsTipState().

◆ COINBASE_FLAGS

CScript COINBASE_FLAGS

Constant stuff for coinbase transactions we create:

Definition at line 107 of file validation.cpp.

Referenced by getblocktemplate(), and IncrementExtraNonce().

◆ cs_main

Global state

Definition at line 62 of file validation.cpp.

Referenced by WalletModel::abandonTransaction(), CWallet::AbandonTransaction(), abandontransaction(), AcceptBlock(), AcceptBlockHeader(), AcceptToMemoryPoolWorker(), ActivateBestChain(), ActivateBestChainStep(), CGovernanceManager::AddGovernanceObject(), addmultisigaddress(), AppInit2(), AutoBackupWallet(), CWallet::AvailableCoins(), backupwallet(), PeerLogicValidation::BlockChecked(), CPrivateSendServer::ChargeFees(), CPrivateSendServer::ChargeRandomFees(), CMasternode::Check(), CMasternodeMan::CheckAndRemove(), CMasternodePing::CheckAndUpdate(), CheckBlock(), CheckBlockIndex(), CMasternode::CheckCollateral(), CheckFinalTx(), CheckForkWarningConditions(), CheckForkWarningConditionsOnNewFork(), CGovernanceManager::CheckMasternodeOrphanObjects(), CGovernanceManager::CheckMasternodeOrphanVotes(), CMasternodeMan::CheckMnbAndUpdateMasternodeList(), CMasternodeBroadcast::CheckOutpoint(), CGovernanceManager::CheckPostponedObjects(), CheckSequenceLocks(), CMasternodePing::CMasternodePing(), CPrivateSendServer::CommitFinalTransaction(), CWallet::CommitTransaction(), ComputeBlockVersion(), ConnectBlock(), CWallet::CountInputsWithAmount(), CPrivateSendClient::CreateDenominated(), CreateNewBlock(), createrawtransaction(), CWallet::CreateTransaction(), decoderawtransaction(), TransactionTablePriv::describe(), DisconnectBlocks(), CMasternodeMan::DoFullVerificationStep(), dumpprivkey(), dumpwallet(), encryptwallet(), FindFilesToPrune(), FlushStateToDisk(), TransactionDesc::FormatTxStatus(), generate(), getaccount(), getaccountaddress(), getaddressesbyaccount(), CWallet::GetAllReserveKeys(), CWallet::GetAnonymizedBalance(), CWallet::GetAverageAnonymizedRounds(), getbalance(), CWallet::GetBalance(), getbestblockhash(), getblock(), getblockchaininfo(), getblockcount(), getblockhash(), GetBlockHash(), getblockheader(), getblockheaders(), getblocktemplate(), getchaintips(), CWallet::GetDenominatedBalance(), CMerkleTx::GetDepthInMainChain(), getdifficulty(), getgenerate(), getgovernanceinfo(), ClientModel::getHeaderTipHeight(), ClientModel::getHeaderTipTime(), CWallet::GetImmatureBalance(), CWallet::GetImmatureWatchOnlyBalance(), getinfo(), ClientModel::getLastBlockDate(), getmininginfo(), getnetworkhashps(), getnetworkinfo(), getnewaddress(), CMasternodeMan::GetNextMasternodeInQueueForPayment(), GetNodeStateStats(), CWallet::GetNormalizedAnonymizedBalance(), ClientModel::getNumBlocks(), WalletModel::getOutputs(), getrawchangeaddress(), getrawtransaction(), getreceivedbyaccount(), getreceivedbyaddress(), GetSpendHeight(), CCoinsViewDB::GetStats(), GetTransaction(), gettransaction(), TransactionTablePriv::getTxHex(), gettxout(), gettxoutproof(), getunconfirmedbalance(), CWallet::GetUnconfirmedBalance(), CWallet::GetUnconfirmedWatchOnlyBalance(), GetUTXOCoins(), GetUTXOConfirmations(), ClientModel::getVerificationProgress(), getwalletinfo(), CWallet::GetWatchOnlyBalance(), gobject(), importaddress(), importelectrumwallet(), importprivkey(), importpubkey(), importwallet(), TransactionTablePriv::index(), InitBlockIndex(), CDSNotificationInterface::InitializeCurrentBlockTip(), instantsendtoaddress(), invalidateblock(), InvalidateBlock(), CGovernanceObject::IsCollateralValid(), CPrivateSend::IsCollateralValid(), CInstantSend::IsEnoughOrphanVotesForTxAndOutPoint(), IsInitialBlockDownload(), WalletModel::isLockedCoin(), WalletModel::isSpent(), CTxLockRequest::IsValid(), keypoolrefill(), listaccounts(), listaddressgroupings(), WalletModel::listCoins(), WalletModel::listLockedCoins(), listlockunspent(), listreceivedbyaccount(), listreceivedbyaddress(), listsinceblock(), listtransactions(), listunspent(), LoadExternalBlockFile(), CWallet::LoadWallet(), WalletModel::lockCoin(), lockunspent(), CPrivateSendClient::MakeCollateralAmounts(), CActiveMasternode::ManageStateLocal(), CWallet::MarkConflicted(), masternode(), masternodelist(), movecmd(), CZMQPublishRawBlockNotifier::NotifyBlock(), NotifyHeaderTip(), WalletModel::pollBalanceChanged(), PrepareShutdown(), WalletModel::prepareTransaction(), prioritisetransaction(), ProcessBlockFound(), ProcessGetData(), CPrivateSendServer::ProcessMessage(), CInstantSend::ProcessMessage(), CMasternodeMan::ProcessMessage(), CGovernanceManager::ProcessMessage(), ProcessMessage(), ProcessNewBlock(), ProcessNewBlockHeaders(), CInstantSend::ProcessOrphanTxLockVotes(), CSporkManager::ProcessSpork(), CInstantSend::ProcessTxLockRequest(), CInstantSend::ProcessTxLockVote(), CWallet::ReacceptWalletTransactions(), reconsiderblock(), ReconsiderBlock(), PeerTablePriv::refreshPeers(), TransactionTablePriv::refreshWallet(), ReprocessBlocks(), CGovernanceManager::RequestGovernanceObjectVotes(), CMasternodePayments::RequestLowDataPaymentBlocks(), resendwallettransactions(), CInstantSend::ResolveConflicts(), rest_block(), rest_getutxos(), rest_headers(), CWallet::ScanForWalletTransactions(), CWallet::SelectCoinsGrouppedByAddresses(), WalletModel::sendCoins(), CPrivateSendClient::SendDenominate(), sendfrom(), sendmany(), SendMessages(), sendrawtransaction(), sendtoaddress(), setaccount(), CMerkleTx::SetMerkleBranch(), setmocktime(), settxfee(), signmessage(), signrawtransaction(), CMasternodePing::SimpleCheck(), TransactionRecord::statusUpdateNeeded(), submitblock(), CGovernanceManager::Sync(), CInstantSend::SyncTransaction(), CPrivateSend::SyncTransaction(), CWallet::SyncTransaction(), TestBlockValidity(), TestLockPointValidity(), TransactionDesc::toHTML(), WalletModel::transactionCanBeAbandoned(), CInstantSend::TryToFinalizeLockCandidate(), UnloadBlockIndex(), WalletModel::unlockCoin(), CGovernanceManager::UpdateCachesAndClean(), CGovernanceObject::UpdateLocalValidity(), CMasternodeMan::UpdateMasternodeList(), TransactionRecord::updateStatus(), TransactionTablePriv::updateWallet(), validateaddress(), verifychain(), CVerifyDB::VerifyDB(), verifymessage(), verifytxoutproof(), VersionBitsTipState(), CInstantSend::Vote(), walletlock(), walletpassphrase(), and walletpassphrasechange().

◆ csBestBlock

Definition at line 67 of file validation.cpp.

Referenced by getblocktemplate().

◆ cvBlockChange

CConditionVariable cvBlockChange

Definition at line 68 of file validation.cpp.

Referenced by getblocktemplate(), OnRPCStopped(), and UpdateTip().

◆ fAddressIndex

◆ fAlerts

bool fAlerts = DEFAULT_ALERTS

Definition at line 85 of file validation.cpp.

Referenced by AppInit2(), and ProcessMessage().

◆ fCheckBlockIndex

bool fCheckBlockIndex = false

Definition at line 81 of file validation.cpp.

Referenced by AppInit2(), and CheckBlockIndex().

◆ fCheckpointsEnabled

bool fCheckpointsEnabled = DEFAULT_CHECKPOINTS_ENABLED

Definition at line 82 of file validation.cpp.

Referenced by AcceptBlockHeader(), AppInit2(), and TestBlockValidity().

◆ fDIP0001ActiveAtTip

std::atomic<bool> fDIP0001ActiveAtTip {false}

◆ fDIP0001WasLockedIn

std::atomic<bool> fDIP0001WasLockedIn {false}

◆ fEnableReplacement

bool fEnableReplacement = DEFAULT_ENABLE_REPLACEMENT

Definition at line 86 of file validation.cpp.

Referenced by AcceptToMemoryPoolWorker(), and AppInit2().

◆ fHavePruned

bool fHavePruned = false

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

Definition at line 76 of file validation.cpp.

Referenced by AppInit2(), CheckBlockIndex(), FlushStateToDisk(), getblock(), LoadBlockIndexDB(), rest_block(), and UnloadBlockIndex().

◆ fImporting

◆ fIsBareMultisigStd

bool fIsBareMultisigStd = DEFAULT_PERMIT_BAREMULTISIG

Definition at line 78 of file validation.cpp.

Referenced by AppInit2(), and IsStandardTx().

◆ fLargeWorkForkFound

◆ fLargeWorkInvalidChainFound

◆ fPruneMode

bool fPruneMode = false

◆ fReindex

◆ fRequireStandard

bool fRequireStandard = true

Definition at line 79 of file validation.cpp.

Referenced by AcceptToMemoryPoolWorker(), and AppInit2().

◆ fSpentIndex

bool fSpentIndex = false

◆ fTimestampIndex

bool fTimestampIndex = false

Definition at line 74 of file validation.cpp.

Referenced by ConnectBlock(), GetTimestampIndex(), InitBlockIndex(), and LoadBlockIndexDB().

◆ fTxIndex

bool fTxIndex = true

◆ hashAssumeValid

uint256 hashAssumeValid

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

Definition at line 91 of file validation.cpp.

Referenced by AppInit2(), and ConnectBlock().

◆ instance_of_cmaincleanup

class CMainCleanup instance_of_cmaincleanup

◆ mapBlockIndex

◆ mempool

◆ minRelayTxFee

◆ nBytesPerSigOp

unsigned int nBytesPerSigOp = DEFAULT_BYTES_PER_SIGOP

Definition at line 80 of file validation.cpp.

Referenced by AcceptToMemoryPoolWorker(), and AppInit2().

◆ nCoinCacheUsage

size_t nCoinCacheUsage = 5000 * 300

Definition at line 83 of file validation.cpp.

Referenced by AppInit2(), FlushStateToDisk(), and CVerifyDB::VerifyDB().

◆ nPruneTarget

uint64_t nPruneTarget = 0

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

Definition at line 84 of file validation.cpp.

Referenced by AppInit2(), and FindFilesToPrune().

◆ nScriptCheckThreads

int nScriptCheckThreads = 0

Definition at line 69 of file validation.cpp.

Referenced by AppInit2(), and ConnectBlock().

◆ nTimeCallbacks

int64_t nTimeCallbacks = 0
static

Definition at line 1953 of file validation.cpp.

Referenced by ConnectBlock().

◆ nTimeChainState

int64_t nTimeChainState = 0
static

Definition at line 2528 of file validation.cpp.

Referenced by ConnectTip().

◆ nTimeCheck

int64_t nTimeCheck = 0
static

Definition at line 1948 of file validation.cpp.

Referenced by ConnectBlock().

◆ nTimeConnect

int64_t nTimeConnect = 0
static

Definition at line 1951 of file validation.cpp.

Referenced by ConnectBlock().

◆ nTimeConnectTotal

int64_t nTimeConnectTotal = 0
static

Definition at line 2526 of file validation.cpp.

Referenced by ConnectTip().

◆ nTimeFlush

int64_t nTimeFlush = 0
static

Definition at line 2527 of file validation.cpp.

Referenced by ConnectTip().

◆ nTimeForks

int64_t nTimeForks = 0
static

Definition at line 1949 of file validation.cpp.

Referenced by ConnectBlock().

◆ nTimeIndex

int64_t nTimeIndex = 0
static

Definition at line 1952 of file validation.cpp.

Referenced by ConnectBlock().

◆ nTimePostConnect

int64_t nTimePostConnect = 0
static

Definition at line 2529 of file validation.cpp.

Referenced by ConnectTip().

◆ nTimeReadFromDisk

int64_t nTimeReadFromDisk = 0
static

Definition at line 2525 of file validation.cpp.

Referenced by ConnectTip().

◆ nTimeTotal

int64_t nTimeTotal = 0
static

Definition at line 1954 of file validation.cpp.

Referenced by ConnectTip().

◆ nTimeVerify

int64_t nTimeVerify = 0
static

Definition at line 1950 of file validation.cpp.

Referenced by ConnectBlock().

◆ pblocktree

CBlockTreeDB* pblocktree = NULL

◆ pcoinsTip

◆ pindexBestForkBase

CBlockIndex * pindexBestForkBase = NULL

◆ pindexBestForkTip

CBlockIndex* pindexBestForkTip = NULL

◆ pindexBestHeader

◆ scriptcheckqueue

CCheckQueue<CScriptCheck> scriptcheckqueue(128)
static

Referenced by ConnectBlock(), and ThreadScriptCheck().

◆ strMessageMagic

◆ versionbitscache

◆ warningcache

Definition at line 1946 of file validation.cpp.

Referenced by UnloadBlockIndex(), and UpdateTip().