Raven Core  3.0.0
P2P Digital Currency
Classes | Macros | Enumerations | Functions | Variables
validation.cpp File Reference
#include "validation.h"
#include "arith_uint256.h"
#include "chain.h"
#include "chainparams.h"
#include "checkpoints.h"
#include "checkqueue.h"
#include "consensus/consensus.h"
#include "consensus/merkle.h"
#include "consensus/tx_verify.h"
#include "consensus/validation.h"
#include "cuckoocache.h"
#include "fs.h"
#include "hash.h"
#include "init.h"
#include "policy/fees.h"
#include "policy/policy.h"
#include "policy/rbf.h"
#include "pow.h"
#include "primitives/block.h"
#include "primitives/transaction.h"
#include "random.h"
#include "reverse_iterator.h"
#include "script/script.h"
#include "script/sigcache.h"
#include "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 "utilmoneystr.h"
#include "utilstrencodings.h"
#include "validationinterface.h"
#include "versionbits.h"
#include "warnings.h"
#include "net.h"
#include <atomic>
#include <sstream>
#include <boost/algorithm/string/replace.hpp>
#include <boost/algorithm/string/join.hpp>
#include <boost/thread.hpp>
#include <script/ismine.h>
#include <wallet/wallet.h>
#include "assets/assets.h"
#include "assets/assetdb.h"
#include "base58.h"
Include dependency graph for validation.cpp:

Go to the source code of this file.

Classes

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

Macros

#define MICRO   0.000001
 
#define MILLI   0.001
 

Enumerations

enum  FlushStateMode { FLUSH_STATE_NONE, FLUSH_STATE_IF_NEEDED, FLUSH_STATE_PERIODIC, FLUSH_STATE_ALWAYS }
 
enum  DisconnectResult { DISCONNECT_OK, DISCONNECT_UNCLEAN, DISCONNECT_FAILED }
 

Functions

std::atomic_bool fImporting (false)
 
std::atomic_bool fReindex (false)
 
CBlockIndexFindForkInGlobalIndex (const CChain &chain, const CBlockLocator &locator)
 Find the last common block between the parameter chain and a locator. More...
 
bool CheckInputs (const CTransaction &tx, CValidationState &state, const CCoinsViewCache &inputs, bool fScriptChecks, unsigned int flags, bool cacheSigStore, bool cacheFullScriptStore, PrecomputedTransactionData &txdata, std::vector< CScriptCheck > *pvChecks)
 Check whether all inputs of this transaction are valid (no double spends, scripts & sigs, amounts) This does not modify the UTXO set. More...
 
bool CheckFinalTx (const CTransaction &tx, int flags)
 Transaction validation functions. More...
 
bool TestLockPointValidity (const LockPoints *lp)
 Test whether the LockPoints height and time are still valid on the current chain. More...
 
bool CheckSequenceLocks (const CTransaction &tx, int flags, LockPoints *lp, bool useExistingLockPoints)
 Check if transaction will be BIP 68 final in the next block to be created. More...
 
std::string FormatStateMessage (const CValidationState &state)
 Convert CValidationState to a human-readable message for logging. More...
 
void UpdateMempoolForReorg (DisconnectedBlockTransactions &disconnectpool, bool fAddToMempool)
 
bool AcceptToMemoryPool (CTxMemPool &pool, CValidationState &state, const CTransactionRef &tx, bool *pfMissingInputs, std::list< CTransactionRef > *plTxnReplaced, bool bypass_limits, const CAmount nAbsurdFee)
 (try to) add transaction to memory pool plTxnReplaced will be appended to with all transactions replaced from mempool More...
 
bool GetTimestampIndex (const unsigned int &high, const unsigned int &low, const bool fActiveOnly, std::vector< std::pair< uint256, unsigned int > > &hashes)
 
bool GetSpentIndex (CSpentIndexKey &key, CSpentIndexValue &value)
 
bool HashOnchainActive (const uint256 &hash)
 
bool GetAddressIndex (uint160 addressHash, int type, std::string assetName, std::vector< std::pair< CAddressIndexKey, CAmount > > &addressIndex, int start, int end)
 
bool GetAddressIndex (uint160 addressHash, int type, std::vector< std::pair< CAddressIndexKey, CAmount > > &addressIndex, int start, int end)
 
bool GetAddressUnspent (uint160 addressHash, int type, std::string assetName, std::vector< std::pair< CAddressUnspentKey, CAddressUnspentValue > > &unspentOutputs)
 
bool GetAddressUnspent (uint160 addressHash, int type, std::vector< std::pair< CAddressUnspentKey, CAddressUnspentValue > > &unspentOutputs)
 
bool GetTransaction (const uint256 &hash, CTransactionRef &txOut, const Consensus::Params &consensusParams, uint256 &hashBlock, bool fAllowSlow)
 Return transaction in txOut, and if it was found inside a block, its hash is placed in hashBlock. 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)
 
CAmount GetBlockSubsidy (int nHeight, const Consensus::Params &consensusParams)
 
bool IsInitialBlockDownload ()
 Check whether we are doing an initial block download (synchronizing from disk or network) More...
 
bool IsInitialSyncSpeedUp ()
 
void UpdateCoins (const CTransaction &tx, CCoinsViewCache &inputs, CTxUndo &txundo, int nHeight, uint256 blockHash, CAssetsCache *assetCache, std::pair< std::string, CBlockAssetUndo > *undoAssetData)
 
void UpdateCoins (const CTransaction &tx, CCoinsViewCache &inputs, int nHeight)
 Apply the effects of this transaction on the UTXO set represented by view. More...
 
int GetSpendHeight (const CCoinsViewCache &inputs)
 RVN END. More...
 
void InitScriptExecutionCache ()
 Initializes the script-execution cache. More...
 
int ApplyTxInUndo (Coin &&undo, CCoinsViewCache &view, const COutPoint &out, CAssetsCache *assetCache=nullptr)
 Restore the UTXO in a Coin at a given COutPoint. More...
 
void ThreadScriptCheck ()
 Run an instance of the script checking thread. More...
 
int32_t ComputeBlockVersion (const CBlockIndex *pindexPrev, const Consensus::Params &params)
 Determine what nVersion a new block should use. More...
 
void FlushStateToDisk ()
 Flush all state, indexes and buffers to disk. More...
 
void PruneAndFlush ()
 Prune block files and flush state to disk. More...
 
bool ActivateBestChain (CValidationState &state, const CChainParams &chainparams, std::shared_ptr< const CBlock > pblock)
 Make the best chain active, in multiple steps. More...
 
bool PreciousBlock (CValidationState &state, const CChainParams &params, CBlockIndex *pindex)
 Mark a block as precious and reorganize. More...
 
bool InvalidateBlock (CValidationState &state, const CChainParams &chainparams, CBlockIndex *pindex)
 Mark a block as invalid. More...
 
bool ResetBlockFailureFlags (CBlockIndex *pindex)
 Remove invalidity status from a block and its descendants. More...
 
bool CheckBlock (const CBlock &block, CValidationState &state, const Consensus::Params &consensusParams, bool fCheckPOW, bool fCheckMerkleRoot)
 Functions for validating blocks and updating the block tree. More...
 
bool IsWitnessEnabled (const CBlockIndex *pindexPrev, const Consensus::Params &params)
 Check whether witness commitments are required for block. More...
 
bool IsWitnessEnabled (const Consensus::Params &params)
 
void UpdateUncommittedBlockStructures (CBlock &block, const CBlockIndex *pindexPrev, const Consensus::Params &consensusParams)
 Update uncommitted block structures (currently: only the witness nonce). 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 ProcessNewBlockHeaders (const std::vector< CBlockHeader > &headers, CValidationState &state, const CChainParams &chainparams, const CBlockIndex **ppindex, CBlockHeader *first_invalid)
 Process incoming block headers. More...
 
bool ProcessNewBlock (const CChainParams &chainparams, const std::shared_ptr< const CBlock > pblock, bool fForceProcessing, bool *fNewBlock)
 Process an incoming block. More...
 
bool TestBlockValidity (CValidationState &state, const CChainParams &chainparams, const CBlock &block, CBlockIndex *pindexPrev, bool fCheckPOW, bool fCheckMerkleRoot)
 Check a block is completely valid from start to finish (only works on top of our current best block, with cs_main held) More...
 
uint64_t CalculateCurrentUsage ()
 BLOCK PRUNING CODE. More...
 
void PruneOneBlockFile (const int fileNumber)
 Mark one block file as pruned. More...
 
void UnlinkPrunedFiles (const std::set< int > &setFilesToPrune)
 Actually unlink the specified files. More...
 
void PruneBlockFilesManual (int nManualPruneHeight)
 Prune block files up to a given height. More...
 
bool CheckDiskSpace (uint64_t nAdditionalBytes)
 Check whether enough disk space is available for an incoming block. More...
 
FILE * OpenBlockFile (const CDiskBlockPos &pos, bool fReadOnly)
 Open a block file (blk?????.dat) More...
 
fs::path GetBlockPosFilename (const CDiskBlockPos &pos, const char *prefix)
 Translation to a filesystem path. More...
 
CBlockIndexInsertBlockIndex (uint256 hash)
 Create a new block index entry for a given block hash. More...
 
bool LoadChainTip (const CChainParams &chainparams)
 Update the chain tip based on database information. More...
 
bool ReplayBlocks (const CChainParams &params, CCoinsView *view)
 Replay blocks that aren't fully applied to the database. 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 UnloadBlockIndex ()
 Unload database information. More...
 
bool LoadBlockIndex (const CChainParams &chainparams)
 Load the block tree and coins database from disk, initializing state if we're running with -reindex. More...
 
bool LoadGenesisBlock (const CChainParams &chainparams)
 Ensures we have a genesis block in the block tree, possibly writing one to disk. More...
 
bool LoadExternalBlockFile (const CChainParams &chainparams, FILE *fileIn, CDiskBlockPos *dbp)
 Import blocks from an external file. More...
 
CBlockFileInfoGetBlockFileInfo (size_t n)
 Get block file info entry for one block file. More...
 
ThresholdState VersionBitsTipState (const Consensus::Params &params, Consensus::DeploymentPos pos)
 Get the BIP9 state for a given deployment at the current tip. More...
 
BIP9Stats VersionBitsTipStatistics (const Consensus::Params &params, Consensus::DeploymentPos pos)
 Get the numerical statistics for the BIP9 state for a given deployment at the current tip. More...
 
int VersionBitsTipStateSinceHeight (const Consensus::Params &params, Consensus::DeploymentPos pos)
 Get the block height at which the BIP9 deployment switched into the state for the block building on the current tip. More...
 
bool LoadMempool (void)
 Load the mempool from disk. More...
 
bool DumpMempool (void)
 Dump the mempool to disk. More...
 
double GuessVerificationProgress (const ChainTxData &data, CBlockIndex *pindex)
 Guess how far we are in the verification process at the given block index. More...
 
bool AreAssetsDeployed ()
 RVN START. More...
 
bool AreMessagingDeployed ()
 
bool AreRestrictedAssetsDeployed ()
 
bool IsDGWActive (unsigned int nBlockNumber)
 
bool IsMessagingActive (unsigned int nBlockNumber)
 
bool IsRestrictedActive (unsigned int nBlockNumber)
 
CAssetsCacheGetCurrentAssetCache ()
 

Variables

CCriticalSection cs_main
 Global state. More...
 
BlockMap mapBlockIndex
 
CChain chainActive
 The currently-connected chain of blocks (protected by cs_main). More...
 
CBlockIndexpindexBestHeader = nullptr
 Best header we've seen so far (used for getheaders queries' starting points). More...
 
CWaitableCriticalSection csBestBlock
 
CConditionVariable cvBlockChange
 
int nScriptCheckThreads = 0
 
bool fMessaging = true
 
bool fTxIndex = false
 
bool fAssetIndex = false
 
bool fAddressIndex = false
 
bool fTimestampIndex = false
 
bool fSpentIndex = false
 
bool fHavePruned = false
 Pruning-related variables and constants. More...
 
bool fPruneMode = false
 True if we're running in -prune mode. More...
 
bool fIsBareMultisigStd = DEFAULT_PERMIT_BAREMULTISIG
 
bool fRequireStandard = true
 
bool fCheckBlockIndex = false
 
bool fCheckpointsEnabled = DEFAULT_CHECKPOINTS_ENABLED
 
size_t nCoinCacheUsage = 5000 * 300
 
uint64_t nPruneTarget = 0
 Number of MiB of block files that we're trying to stay below. More...
 
int64_t nMaxTipAge = DEFAULT_MAX_TIP_AGE
 If the tip is older than this (in seconds), the node is considered to be in initial block download. More...
 
bool fEnableReplacement = DEFAULT_ENABLE_REPLACEMENT
 
bool fUnitTest = false
 
uint256 hashAssumeValid
 Block hash whose ancestors we will assume to have valid scripts without checking them. More...
 
arith_uint256 nMinimumChainWork
 Minimum work we will assume exists on some valid chain. More...
 
CFeeRate minRelayTxFee = CFeeRate(DEFAULT_MIN_RELAY_TX_FEE)
 A fee rate smaller than this is considered zero fee (for relaying, mining and transaction creation) More...
 
CAmount maxTxFee = DEFAULT_TRANSACTION_MAXFEE
 Absolute maximum transaction fee (in satoshis) used by wallet and mempool (rejects high fee in sendrawtransaction) More...
 
CFeeRate minRelayTxFeeV2 = CFeeRate(DEFAULT_MIN_RELAY_TX_FEE_V2)
 A fee rate smaller than this is considered zero fee (for relaying, mining and transaction creation) More...
 
CBlockPolicyEstimator feeEstimator
 
CScript COINBASE_FLAGS
 Constant stuff for coinbase transactions we create: More...
 
const std::string strMessageMagic = "Raven Signed Message:\n"
 
CCoinsViewDBpcoinsdbview = nullptr
 Global variable that points to the coins database (protected by cs_main) More...
 
CCoinsViewCachepcoinsTip = nullptr
 Global variable that points to the active CCoinsView (protected by cs_main) More...
 
CBlockTreeDBpblocktree = nullptr
 Global variable that points to the active block tree (protected by cs_main) More...
 
CAssetsDBpassetsdb = nullptr
 RVN START. More...
 
CAssetsCachepassets = nullptr
 Global variable that point to the active assets (protected by cs_main) More...
 
CLRUCache< std::string, CDatabasedAssetData > * passetsCache = nullptr
 Global variable that point to the assets metadata LRU Cache (protected by cs_main) More...
 
CLRUCache< std::string, CMessage > * pMessagesCache = nullptr
 Global variable that points to the subscribed channel LRU Cache (protected by cs_main) More...
 
CLRUCache< std::string, int > * pMessageSubscribedChannelsCache = nullptr
 Global variable that points to the subscribed channel LRU Cache (protected by cs_main) More...
 
CLRUCache< std::string, int > * pMessagesSeenAddressCache = nullptr
 Global variable that points to the address seen LRU Cache (protected by cs_main) More...
 
CMessageDBpmessagedb = nullptr
 Global variable that points to the messages database (protected by cs_main) More...
 
CMessageChannelDBpmessagechanneldb = nullptr
 Global variable that points to the message channel database (protected by cs_main) More...
 
CLRUCache< std::string, CNullAssetTxVerifierString > * passetsVerifierCache = nullptr
 Global variable that points to the asset verifier LRU Cache (protected by cs_main) More...
 
CLRUCache< std::string, int8_t > * passetsQualifierCache = nullptr
 Global variable that points to the asset address qualifier LRU Cache (protected by cs_main) More...
 
CLRUCache< std::string, int8_t > * passetsRestrictionCache = nullptr
 Global variable that points to the asset address restriction LRU Cache (protected by cs_main) More...
 
CLRUCache< std::string, int8_t > * passetsGlobalRestrictionCache = nullptr
 Global variable that points to the global asset restriction LRU Cache (protected by cs_main) More...
 
CRestrictedDBprestricteddb = nullptr
 Global variable that points to the active restricted asset database (protected by cs_main) More...
 
CBlockIndexpindexBestForkTip = nullptr
 
CBlockIndexpindexBestForkBase = nullptr
 
VersionBitsCache versionbitscache
 
class CMainCleanup instance_of_cmaincleanup
 

Macro Definition Documentation

◆ MICRO

#define MICRO   0.000001

Definition at line 64 of file validation.cpp.

◆ MILLI

#define MILLI   0.001

Definition at line 65 of file validation.cpp.

Enumeration Type Documentation

◆ DisconnectResult

Enumerator
DISCONNECT_OK 
DISCONNECT_UNCLEAN 
DISCONNECT_FAILED 

Definition at line 1683 of file validation.cpp.

◆ FlushStateMode

Enumerator
FLUSH_STATE_NONE 
FLUSH_STATE_IF_NEEDED 
FLUSH_STATE_PERIODIC 
FLUSH_STATE_ALWAYS 

Definition at line 241 of file validation.cpp.

Function Documentation

◆ AcceptToMemoryPool()

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

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

Definition at line 1037 of file validation.cpp.

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

◆ ActivateBestChain()

bool ActivateBestChain ( CValidationState state,
const CChainParams chainparams,
std::shared_ptr< const CBlock pblock 
)

Make the best chain active, in multiple steps.

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

The result is either failure or an activated best chain. pblock is either nullptr or a pointer to a block that is already loaded (to avoid loading it again from disk).

Definition at line 3459 of file validation.cpp.

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

◆ ApplyTxInUndo()

int ApplyTxInUndo ( Coin &&  undo,
CCoinsViewCache view,
const COutPoint out,
CAssetsCache assetCache = nullptr 
)

Restore the UTXO in a Coin at a given COutPoint.

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

RVN START

RVN END

RVN START

RVN END

Definition at line 1697 of file validation.cpp.

Here is the call graph for this function:

◆ AreAssetsDeployed()

bool AreAssetsDeployed ( )

RVN START.

Definition at line 5592 of file validation.cpp.

Here is the caller graph for this function:

◆ AreMessagingDeployed()

bool AreMessagingDeployed ( )

Definition at line 5604 of file validation.cpp.

Here is the caller graph for this function:

◆ AreRestrictedAssetsDeployed()

bool AreRestrictedAssetsDeployed ( )

Definition at line 5616 of file validation.cpp.

Here is the caller graph for this function:

◆ CalculateCurrentUsage()

uint64_t CalculateCurrentUsage ( )

BLOCK PRUNING CODE.

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

Definition at line 4358 of file validation.cpp.

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

Here is the caller graph for this function:

◆ CheckDiskSpace()

bool CheckDiskSpace ( uint64_t  nAdditionalBytes)

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

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

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

◆ CheckInputs()

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

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

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

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

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

Definition at line 1523 of file validation.cpp.

Here is the call graph for this function:

◆ CheckSequenceLocks()

bool CheckSequenceLocks ( 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 305 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.

If the assets are deployed now. We need to use the correct block version

Definition at line 2225 of file validation.cpp.

Here is the caller graph for this function:

◆ DumpMempool()

bool DumpMempool ( )

Dump the mempool to disk.

Definition at line 5524 of file validation.cpp.

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

◆ fImporting()

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

◆ FindForkInGlobalIndex()

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

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

Definition at line 204 of file validation.cpp.

Here is the call graph for this function:

◆ FlushStateToDisk()

void FlushStateToDisk ( )

Flush all state, indexes and buffers to disk.

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

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

◆ fReindex()

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

◆ GenerateCoinbaseCommitment()

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

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

Definition at line 3932 of file validation.cpp.

Here is the caller graph for this function:

◆ GetAddressIndex() [1/2]

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

Definition at line 1081 of file validation.cpp.

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

◆ GetAddressIndex() [2/2]

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

Definition at line 1093 of file validation.cpp.

Here is the call graph for this function:

◆ GetAddressUnspent() [1/2]

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

Definition at line 1105 of file validation.cpp.

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

◆ GetAddressUnspent() [2/2]

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

Definition at line 1117 of file validation.cpp.

Here is the call graph for this function:

◆ GetBlockFileInfo()

CBlockFileInfo* GetBlockFileInfo ( size_t  n)

Get block file info entry for one block file.

Definition at line 5421 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 4549 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 1253 of file validation.cpp.

◆ GetCurrentAssetCache()

CAssetsCache* GetCurrentAssetCache ( )

Definition at line 5649 of file validation.cpp.

Here is the caller graph for this function:

◆ GetSpendHeight()

int GetSpendHeight ( const CCoinsViewCache inputs)

RVN END.

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

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

◆ GetSpentIndex()

bool GetSpentIndex ( CSpentIndexKey key,
CSpentIndexValue value 
)

Definition at line 1056 of file validation.cpp.

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

◆ GetTimestampIndex()

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

Definition at line 1045 of file validation.cpp.

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

◆ GetTransaction()

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

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

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

Definition at line 1130 of file validation.cpp.

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

◆ GuessVerificationProgress()

double GuessVerificationProgress ( const ChainTxData data,
CBlockIndex pindex 
)

Guess how far we are in the verification process at the given block index.

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

Definition at line 5574 of file validation.cpp.

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

◆ HashOnchainActive()

bool HashOnchainActive ( const uint256 hash)

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

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

◆ InsertBlockIndex()

CBlockIndex* InsertBlockIndex ( uint256  hash)

Create a new block index entry for a given block hash.

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

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

◆ IsDGWActive()

bool IsDGWActive ( unsigned int  nBlockNumber)

Definition at line 5628 of file validation.cpp.

Here is the call graph for this function:

◆ IsInitialBlockDownload()

bool IsInitialBlockDownload ( )

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

Definition at line 1266 of file validation.cpp.

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

◆ IsInitialSyncSpeedUp()

bool IsInitialSyncSpeedUp ( )

Definition at line 1304 of file validation.cpp.

Here is the call graph for this function:

◆ IsMessagingActive()

bool IsMessagingActive ( unsigned int  nBlockNumber)

Definition at line 5632 of file validation.cpp.

Here is the call graph for this function:

◆ IsRestrictedActive()

bool IsRestrictedActive ( unsigned int  nBlockNumber)

Definition at line 5640 of file validation.cpp.

Here is the call graph for this function:

◆ IsWitnessEnabled() [1/2]

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

Check whether witness commitments are required for block.

Definition at line 3897 of file validation.cpp.

Here is the caller graph for this function:

◆ IsWitnessEnabled() [2/2]

bool IsWitnessEnabled ( const Consensus::Params params)

Definition at line 3902 of file validation.cpp.

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

Here is the call graph for this function:

◆ LoadExternalBlockFile()

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

Import blocks from an external file.

Definition at line 5114 of file validation.cpp.

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

◆ LoadGenesisBlock()

bool LoadGenesisBlock ( const CChainParams chainparams)

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

Definition at line 5083 of file validation.cpp.

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

◆ LoadMempool()

bool LoadMempool ( )

Load the mempool from disk.

Definition at line 5448 of file validation.cpp.

Here is the call graph for this function:

◆ OpenBlockFile()

FILE* OpenBlockFile ( const CDiskBlockPos pos,
bool  fReadOnly 
)

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

Definition at line 4540 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.

Definition at line 3531 of file validation.cpp.

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

◆ ProcessNewBlock()

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

Process an incoming block.

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

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

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

Call without cs_main held.

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

Call without cs_main held.

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 4185 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 2965 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 4437 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 4370 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 1219 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 1243 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 4844 of file validation.cpp.

Here is the call graph for this function:

◆ ResetBlockFailureFlags()

bool ResetBlockFailureFlags ( CBlockIndex pindex)

Remove invalidity status from a block and its descendants.

Definition at line 3620 of file validation.cpp.

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

◆ RewindBlockIndex()

bool RewindBlockIndex ( const CChainParams params)

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

Definition at line 4912 of file validation.cpp.

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

◆ TestBlockValidity()

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

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

RVN START

RVN END

RVN START

RVN END

Definition at line 4326 of file validation.cpp.

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

◆ TestLockPointValidity()

bool TestLockPointValidity ( const LockPoints lp)

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

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

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

◆ UnlinkPrunedFiles()

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

Actually unlink the specified files.

Definition at line 4404 of file validation.cpp.

Here is the call graph for this function:

◆ UnloadBlockIndex()

void UnloadBlockIndex ( )

Unload database information.

Definition at line 5008 of file validation.cpp.

Here is the call graph for this function:

◆ UpdateCoins() [1/2]

void UpdateCoins ( const CTransaction tx,
CCoinsViewCache inputs,
CTxUndo txundo,
int  nHeight,
uint256  blockHash,
CAssetsCache assetCache,
std::pair< std::string, CBlockAssetUndo > *  undoAssetData 
)

RVN START

RVN END

RVN START

RVN END

Definition at line 1462 of file validation.cpp.

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

◆ UpdateCoins() [2/2]

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

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

Definition at line 1477 of file validation.cpp.

Here is the call graph for this function:

◆ UpdateMempoolForReorg()

void UpdateMempoolForReorg ( DisconnectedBlockTransactions disconnectpool,
bool  fAddToMempool 
)

Definition at line 426 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 nonce).

This is safe for submitted blocks.

Definition at line 3920 of file validation.cpp.

Here is the caller graph for this function:

◆ VersionBitsTipState()

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

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

Definition at line 5428 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 5440 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 5434 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 75 of file validation.cpp.

◆ COINBASE_FLAGS

CScript COINBASE_FLAGS

Constant stuff for coinbase transactions we create:

Definition at line 115 of file validation.cpp.

◆ cs_main

Global state.

Definition at line 72 of file validation.cpp.

◆ csBestBlock

Definition at line 77 of file validation.cpp.

◆ cvBlockChange

CConditionVariable cvBlockChange

Definition at line 78 of file validation.cpp.

◆ fAddressIndex

bool fAddressIndex = false

Definition at line 85 of file validation.cpp.

◆ fAssetIndex

bool fAssetIndex = false

Definition at line 84 of file validation.cpp.

◆ fCheckBlockIndex

bool fCheckBlockIndex = false

Definition at line 92 of file validation.cpp.

◆ fCheckpointsEnabled

bool fCheckpointsEnabled = DEFAULT_CHECKPOINTS_ENABLED

Definition at line 93 of file validation.cpp.

◆ feeEstimator

CTxMemPool mempool & feeEstimator

Definition at line 109 of file validation.cpp.

◆ fEnableReplacement

bool fEnableReplacement = DEFAULT_ENABLE_REPLACEMENT

Definition at line 97 of file validation.cpp.

◆ fHavePruned

bool fHavePruned = false

Pruning-related variables and constants.

True if any block files have ever been pruned.

Definition at line 88 of file validation.cpp.

◆ fIsBareMultisigStd

bool fIsBareMultisigStd = DEFAULT_PERMIT_BAREMULTISIG

Definition at line 90 of file validation.cpp.

◆ fMessaging

bool fMessaging = true

Definition at line 82 of file validation.cpp.

◆ fPruneMode

bool fPruneMode = false

True if we're running in -prune mode.

Definition at line 89 of file validation.cpp.

◆ fRequireStandard

bool fRequireStandard = true

Definition at line 91 of file validation.cpp.

◆ fSpentIndex

bool fSpentIndex = false

Definition at line 87 of file validation.cpp.

◆ fTimestampIndex

bool fTimestampIndex = false

Definition at line 86 of file validation.cpp.

◆ fTxIndex

bool fTxIndex = false

Definition at line 83 of file validation.cpp.

◆ fUnitTest

bool fUnitTest = false

Definition at line 99 of file validation.cpp.

◆ hashAssumeValid

uint256 hashAssumeValid

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

Definition at line 101 of file validation.cpp.

◆ instance_of_cmaincleanup

class CMainCleanup instance_of_cmaincleanup

◆ mapBlockIndex

BlockMap mapBlockIndex

Definition at line 74 of file validation.cpp.

◆ maxTxFee

CAmount maxTxFee = DEFAULT_TRANSACTION_MAXFEE

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

Definition at line 105 of file validation.cpp.

◆ minRelayTxFee

CFeeRate minRelayTxFee = CFeeRate(DEFAULT_MIN_RELAY_TX_FEE)

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

Definition at line 104 of file validation.cpp.

◆ minRelayTxFeeV2

CFeeRate minRelayTxFeeV2 = CFeeRate(DEFAULT_MIN_RELAY_TX_FEE_V2)

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

Definition at line 107 of file validation.cpp.

◆ nCoinCacheUsage

size_t nCoinCacheUsage = 5000 * 300

Definition at line 94 of file validation.cpp.

◆ nMaxTipAge

int64_t nMaxTipAge = DEFAULT_MAX_TIP_AGE

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

Definition at line 96 of file validation.cpp.

◆ nMinimumChainWork

arith_uint256 nMinimumChainWork

Minimum work we will assume exists on some valid chain.

Definition at line 102 of file validation.cpp.

◆ nPruneTarget

uint64_t nPruneTarget = 0

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

Definition at line 95 of file validation.cpp.

◆ nScriptCheckThreads

int nScriptCheckThreads = 0

Definition at line 79 of file validation.cpp.

◆ passets

CAssetsCache* passets = nullptr

Global variable that point to the active assets (protected by cs_main)

Definition at line 227 of file validation.cpp.

◆ passetsCache

CLRUCache<std::string, CDatabasedAssetData>* passetsCache = nullptr

Global variable that point to the assets metadata LRU Cache (protected by cs_main)

Definition at line 228 of file validation.cpp.

◆ passetsdb

CAssetsDB* passetsdb = nullptr

RVN START.

Global variable that point to the active assets database (protected by cs_main)

Definition at line 226 of file validation.cpp.

◆ passetsGlobalRestrictionCache

CLRUCache<std::string, int8_t>* passetsGlobalRestrictionCache = nullptr

Global variable that points to the global asset restriction LRU Cache (protected by cs_main)

Definition at line 238 of file validation.cpp.

◆ passetsQualifierCache

CLRUCache<std::string, int8_t>* passetsQualifierCache = nullptr

Global variable that points to the asset address qualifier LRU Cache (protected by cs_main)

Definition at line 236 of file validation.cpp.

◆ passetsRestrictionCache

CLRUCache<std::string, int8_t>* passetsRestrictionCache = nullptr

Global variable that points to the asset address restriction LRU Cache (protected by cs_main)

Definition at line 237 of file validation.cpp.

◆ passetsVerifierCache

CLRUCache<std::string, CNullAssetTxVerifierString>* passetsVerifierCache = nullptr

Global variable that points to the asset verifier LRU Cache (protected by cs_main)

Definition at line 235 of file validation.cpp.

◆ pblocktree

CBlockTreeDB* pblocktree = nullptr

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

Definition at line 224 of file validation.cpp.

◆ pcoinsdbview

CCoinsViewDB* pcoinsdbview = nullptr

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

Definition at line 222 of file validation.cpp.

◆ pcoinsTip

CCoinsViewCache* pcoinsTip = nullptr

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

Definition at line 223 of file validation.cpp.

◆ pindexBestForkBase

CBlockIndex * pindexBestForkBase = nullptr

Definition at line 1342 of file validation.cpp.

◆ pindexBestForkTip

CBlockIndex* pindexBestForkTip = nullptr

Definition at line 1342 of file validation.cpp.

◆ pindexBestHeader

CBlockIndex* pindexBestHeader = nullptr

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

Definition at line 76 of file validation.cpp.

◆ pmessagechanneldb

CMessageChannelDB* pmessagechanneldb = nullptr

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

Definition at line 233 of file validation.cpp.

◆ pmessagedb

CMessageDB* pmessagedb = nullptr

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

Definition at line 232 of file validation.cpp.

◆ pMessagesCache

CLRUCache<std::string, CMessage>* pMessagesCache = nullptr

Global variable that points to the subscribed channel LRU Cache (protected by cs_main)

Definition at line 229 of file validation.cpp.

◆ pMessagesSeenAddressCache

CLRUCache<std::string, int>* pMessagesSeenAddressCache = nullptr

Global variable that points to the address seen LRU Cache (protected by cs_main)

Definition at line 231 of file validation.cpp.

◆ pMessageSubscribedChannelsCache

CLRUCache<std::string, int>* pMessageSubscribedChannelsCache = nullptr

Global variable that points to the subscribed channel LRU Cache (protected by cs_main)

Definition at line 230 of file validation.cpp.

◆ prestricteddb

CRestrictedDB* prestricteddb = nullptr

Global variable that points to the active restricted asset database (protected by cs_main)

Definition at line 239 of file validation.cpp.

◆ strMessageMagic

const std::string strMessageMagic = "Raven Signed Message:\n"

Definition at line 117 of file validation.cpp.

◆ versionbitscache

VersionBitsCache versionbitscache

Definition at line 2223 of file validation.cpp.