Dogecoin Core
1.14.2
P2P Digital Currency
|
#include "amount.h"
#include "chain.h"
#include "coins.h"
#include "protocol.h"
#include "script/script_error.h"
#include "sync.h"
#include "versionbits.h"
#include <algorithm>
#include <exception>
#include <map>
#include <set>
#include <stdint.h>
#include <string>
#include <utility>
#include <vector>
#include <atomic>
#include <boost/unordered_map.hpp>
#include <boost/filesystem/path.hpp>
Go to the source code of this file.
Classes | |
struct | BlockHasher |
class | CScriptCheck |
Closure representing one script verification Note that this stores references to the spending transaction. More... | |
class | CVerifyDB |
RAII wrapper for VerifyDB: Verify consistency of the block and coin databases. More... | |
Namespaces | |
Consensus | |
Typedefs | |
typedef boost::unordered_map< uint256, CBlockIndex *, BlockHasher > | BlockMap |
Functions | |
bool | ProcessNewBlock (const CChainParams &chainparams, const std::shared_ptr< const CBlock > pblock, bool fForceProcessing, bool *fNewBlock) |
Process an incoming block. More... | |
bool | ProcessNewBlockHeaders (const std::vector< CBlockHeader > &block, CValidationState &state, const CChainParams &chainparams, const CBlockIndex **ppindex=NULL) |
Process incoming block headers. More... | |
bool | CheckDiskSpace (uint64_t nAdditionalBytes=0) |
Check whether enough disk space is available for an incoming block. More... | |
FILE * | OpenBlockFile (const CDiskBlockPos &pos, bool fReadOnly=false) |
Open a block file (blk?????.dat) More... | |
FILE * | OpenUndoFile (const CDiskBlockPos &pos, bool fReadOnly=false) |
Open an undo file (rev?????.dat) More... | |
boost::filesystem::path | GetBlockPosFilename (const CDiskBlockPos &pos, const char *prefix) |
Translation to a filesystem path. More... | |
bool | LoadExternalBlockFile (const CChainParams &chainparams, FILE *fileIn, CDiskBlockPos *dbp=NULL) |
Import blocks from an external file. More... | |
bool | InitBlockIndex (const CChainParams &chainparams) |
Initialize a new block tree database + block data on disk. More... | |
bool | LoadBlockIndex (const CChainParams &chainparams) |
Load the block tree and coins database from disk. More... | |
void | UnloadBlockIndex () |
Unload database information. More... | |
void | ThreadScriptCheck () |
Run an instance of the script checking thread. More... | |
bool | IsInitialBlockDownload () |
Check whether we are doing an initial block download (synchronizing from disk or network) More... | |
std::string | GetWarnings (const std::string &strFor) |
Format a string that describes several potential problems detected by the core. More... | |
bool | GetTransaction (const uint256 &hash, CTransactionRef &tx, const Consensus::Params ¶ms, uint256 &hashBlock, bool fAllowSlow=false) |
Retrieve a transaction (from memory pool, or from disk, if possible) More... | |
bool | ActivateBestChain (CValidationState &state, const CChainParams &chainparams, std::shared_ptr< const CBlock > pblock=std::shared_ptr< const CBlock >()) |
Find the best known block, and make it the tip of the block chain. More... | |
CAmount | GetBlockSubsidy (int nHeight, const Consensus::Params &consensusParams) |
double | GuessVerificationProgress (const ChainTxData &data, CBlockIndex *pindex) |
Guess verification progress (as a fraction between 0.0=genesis and 1.0=current tip). More... | |
uint64_t | CalculateCurrentUsage () |
Calculate the amount of disk space the block & undo files currently use. More... | |
void | FindFilesToPrune (std::set< int > &setFilesToPrune, uint64_t nPruneAfterHeight) |
Prune block and undo files (blk???.dat and undo???.dat) so that the disk space used is less than a user-defined target. More... | |
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... | |
CBlockIndex * | InsertBlockIndex (uint256 hash) |
Create a new block index entry for a given block hash. More... | |
void | FlushStateToDisk () |
Flush all state, indexes and buffers to disk. More... | |
void | PruneAndFlush () |
Prune block files and flush state to disk. More... | |
void | PruneBlockFilesManual (int nPruneUpToHeight) |
Prune block files up to a given height. More... | |
bool | AcceptToMemoryPool (CTxMemPool &pool, CValidationState &state, const CTransactionRef &tx, bool fLimitFree, bool *pfMissingInputs, std::list< CTransactionRef > *plTxnReplaced=NULL, bool fOverrideMempoolLimit=false, const CAmount nAbsurdFee=0) |
(try to) add transaction to memory pool plTxnReplaced will be appended to with all transactions replaced from mempool More... | |
bool | AcceptToMemoryPoolWithTime (CTxMemPool &pool, CValidationState &state, const CTransactionRef &tx, bool fLimitFree, bool *pfMissingInputs, int64_t nAcceptTime, std::list< CTransactionRef > *plTxnReplaced=NULL, bool fOverrideMempoolLimit=false, const CAmount nAbsurdFee=0) |
(try to) add transaction to memory pool with a specified acceptance time More... | |
std::string | FormatStateMessage (const CValidationState &state) |
Convert CValidationState to a human-readable message for logging. More... | |
ThresholdState | VersionBitsTipState (const Consensus::Params ¶ms, Consensus::DeploymentPos pos) |
Get the BIP9 state for a given deployment at the current tip. More... | |
int | VersionBitsTipStateSinceHeight (const Consensus::Params ¶ms, 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... | |
unsigned int | GetLegacySigOpCount (const CTransaction &tx) |
Count ECDSA signature operations the old-fashioned (pre-0.6) way. More... | |
unsigned int | GetP2SHSigOpCount (const CTransaction &tx, const CCoinsViewCache &mapInputs) |
Count ECDSA signature operations in pay-to-script-hash inputs. More... | |
int64_t | GetTransactionSigOpCost (const CTransaction &tx, const CCoinsViewCache &inputs, int flags) |
Compute total signature operation cost of a transaction. More... | |
bool | CheckInputs (const CTransaction &tx, CValidationState &state, const CCoinsViewCache &view, bool fScriptChecks, unsigned int flags, bool cacheStore, PrecomputedTransactionData &txdata, 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. More... | |
void | UpdateCoins (const CTransaction &tx, CCoinsViewCache &inputs, int nHeight) |
Apply the effects of this transaction on the UTXO set represented by view. More... | |
bool | CheckTransaction (const CTransaction &tx, CValidationState &state, bool fCheckDuplicateInputs=true) |
Transaction validation functions. More... | |
bool | Consensus::CheckTxInputs (const CChainParams ¶ms, const CTransaction &tx, CValidationState &state, const CCoinsViewCache &inputs, int nSpendHeight) |
Check whether all inputs of this transaction are valid (no double spends and amounts) This does not modify the UTXO set. More... | |
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. More... | |
bool | CheckFinalTx (const CTransaction &tx, int flags=-1) |
Check if transaction will be final in the next block to be created. More... | |
bool | TestLockPointValidity (const LockPoints *lp) |
Test whether the LockPoints height and time are still valid on the current chain. More... | |
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. More... | |
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. More... | |
bool | WriteBlockToDisk (const CBlock &block, CDiskBlockPos &pos, const CMessageHeader::MessageStartChars &messageStart) |
Functions for disk access for blocks. More... | |
bool | ReadBlockFromDisk (CBlock &block, const CDiskBlockPos &pos, const Consensus::Params &consensusParams, bool fCheckPOW=true) |
bool | ReadBlockFromDisk (CBlock &block, const CBlockIndex *pindex, const Consensus::Params &consensusParams, bool fCheckPOW=true) |
bool | ReadBlockHeaderFromDisk (CBlockHeader &block, const CBlockIndex *pindex, const Consensus::Params &consensusParams, bool fCheckPOW=true) |
bool | CheckBlockHeader (const CBlockHeader &block, CValidationState &state, bool fCheckPOW=true) |
Functions for validating blocks and updating the block tree. More... | |
bool | CheckBlock (const CBlock &block, CValidationState &state, bool fCheckPOW=true, bool fCheckMerkleRoot=true) |
bool | ContextualCheckBlockHeader (const CBlockHeader &block, CValidationState &state, const CBlockIndex *pindexPrev, int64_t nAdjustedTime) |
Context-dependent validity checks. More... | |
bool | ContextualCheckBlock (const CBlock &block, CValidationState &state, const CBlockIndex *pindexPrev) |
bool | ConnectBlock (const CBlock &block, CValidationState &state, CBlockIndex *pindex, CCoinsViewCache &coins, const CChainParams &chainparams, bool fJustCheck=false) |
Apply the effects of this block (with given index) on the UTXO set represented by coins. More... | |
bool | DisconnectBlock (const CBlock &block, CValidationState &state, const CBlockIndex *pindex, CCoinsViewCache &coins, bool *pfClean=NULL) |
Undo the effects of this block (with given index) on the UTXO set represented by coins. More... | |
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) More... | |
bool | IsWitnessEnabled (const CBlockIndex *pindexPrev, const Consensus::Params ¶ms) |
Check whether witness commitments are required for block. More... | |
bool | RewindBlockIndex (const CChainParams ¶ms) |
When there are blocks in the active chain with missing data, rewind the chainstate and remove them from the block index. More... | |
void | UpdateUncommittedBlockStructures (CBlock &block, const CBlockIndex *pindexPrev, const Consensus::Params &consensusParams) |
Update uncommitted block structures (currently: only the witness 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... | |
CBlockIndex * | FindForkInGlobalIndex (const CChain &chain, const CBlockLocator &locator) |
Find the last common block between the parameter chain and a locator. More... | |
bool | PreciousBlock (CValidationState &state, const CChainParams ¶ms, 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... | |
int | GetSpendHeight (const CCoinsViewCache &inputs) |
Return the spend height, which is one more than the inputs.GetBestBlock(). More... | |
int32_t | ComputeBlockVersion (const CBlockIndex *pindexPrev, const Consensus::Params ¶ms) |
Determine what nVersion a new block should use. More... | |
CBlockFileInfo * | GetBlockFileInfo (size_t n) |
Get block file info entry for one block file. More... | |
void | DumpMempool () |
Dump the mempool to disk. More... | |
bool | LoadMempool () |
Load the mempool from disk. More... | |
Variables | |
CScript | COINBASE_FLAGS |
Constant stuff for coinbase transactions we create: More... | |
CCriticalSection | cs_main |
Global state. More... | |
CTxMemPool | mempool |
BlockMap | mapBlockIndex |
uint64_t | nLastBlockTx |
uint64_t | nLastBlockSize |
uint64_t | nLastBlockWeight |
const std::string | strMessageMagic |
CWaitableCriticalSection | csBestBlock |
CConditionVariable | cvBlockChange |
std::atomic_bool | fImporting |
bool | fReindex |
int | nScriptCheckThreads |
bool | fTxIndex |
bool | fIsBareMultisigStd |
bool | fRequireStandard |
bool | fCheckBlockIndex |
bool | fCheckpointsEnabled |
size_t | nCoinCacheUsage |
CFeeRate | minRelayTxFee |
A fee rate smaller than this is considered zero fee (for relaying, mining and transaction creation) More... | |
CAmount | maxTxFee |
Absolute maximum transaction fee (in satoshis) used by wallet and mempool (rejects high fee in sendrawtransaction) More... | |
bool | fAlerts |
int64_t | nMaxTipAge |
If the tip is older than this (in seconds), the node is considered to be in initial block download. More... | |
bool | fEnableReplacement |
uint256 | hashAssumeValid |
Block hash whose ancestors we will assume to have valid scripts without checking them. More... | |
CBlockIndex * | pindexBestHeader |
Best header we've seen so far (used for getheaders queries' starting points). More... | |
bool | fHavePruned |
Pruning-related variables and constants. More... | |
bool | fPruneMode |
True if we're running in -prune mode. More... | |
uint64_t | nPruneTarget |
Number of MiB of block files that we're trying to stay below. More... | |
CChain | chainActive |
The currently-connected chain of blocks (protected by cs_main). More... | |
CCoinsViewCache * | pcoinsTip |
Global variable that points to the active CCoinsView (protected by cs_main) More... | |
CBlockTreeDB * | pblocktree |
Global variable that points to the active block tree (protected by cs_main) More... | |
VersionBitsCache | versionbitscache |
typedef boost::unordered_map<uint256, CBlockIndex*, BlockHasher> BlockMap |
Definition at line 160 of file validation.h.
bool AcceptToMemoryPool | ( | CTxMemPool & | pool, |
CValidationState & | state, | ||
const CTransactionRef & | tx, | ||
bool | fLimitFree, | ||
bool * | pfMissingInputs, | ||
std::list< CTransactionRef > * | plTxnReplaced = NULL , |
||
bool | fOverrideMempoolLimit = false , |
||
const CAmount | nAbsurdFee = 0 |
||
) |
(try to) add transaction to memory pool plTxnReplaced will be appended to with all transactions replaced from mempool
Definition at line 1045 of file validation.cpp.
bool AcceptToMemoryPoolWithTime | ( | CTxMemPool & | pool, |
CValidationState & | state, | ||
const CTransactionRef & | tx, | ||
bool | fLimitFree, | ||
bool * | pfMissingInputs, | ||
int64_t | nAcceptTime, | ||
std::list< CTransactionRef > * | plTxnReplaced = NULL , |
||
bool | fOverrideMempoolLimit = false , |
||
const CAmount | nAbsurdFee = 0 |
||
) |
(try to) add transaction to memory pool with a specified acceptance time
Definition at line 1029 of file validation.cpp.
bool ActivateBestChain | ( | CValidationState & | state, |
const CChainParams & | chainparams, | ||
std::shared_ptr< const CBlock > | pblock | ||
) |
Find the best known block, and make it the tip of the block chain.
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 NULL or a pointer to a block that is already loaded (to avoid loading it again from disk).
Definition at line 2496 of file validation.cpp.
uint64_t CalculateCurrentUsage | ( | ) |
Calculate the amount of disk space the block & undo files currently use.
Calculate the amount of disk space the block & undo files currently use.
Definition at line 3357 of file validation.cpp.
bool CheckBlock | ( | const CBlock & | block, |
CValidationState & | state, | ||
bool | fCheckPOW = true , |
||
bool | fCheckMerkleRoot = true |
||
) |
Definition at line 2865 of file validation.cpp.
bool CheckBlockHeader | ( | const CBlockHeader & | block, |
CValidationState & | state, | ||
bool | fCheckPOW = true |
||
) |
Functions for validating blocks and updating the block tree.
Context-independent validity checks
Definition at line 2853 of file validation.cpp.
bool CheckDiskSpace | ( | uint64_t | nAdditionalBytes = 0 | ) |
Check whether enough disk space is available for an incoming block.
Definition at line 3490 of file validation.cpp.
bool CheckFinalTx | ( | const CTransaction & | tx, |
int | flags = -1 |
||
) |
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 250 of file validation.cpp.
bool CheckInputs | ( | const CTransaction & | tx, |
CValidationState & | state, | ||
const CCoinsViewCache & | view, | ||
bool | fScriptChecks, | ||
unsigned int | flags, | ||
bool | cacheStore, | ||
PrecomputedTransactionData & | txdata, | ||
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 1441 of file validation.cpp.
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 383 of file validation.cpp.
bool CheckTransaction | ( | const CTransaction & | tx, |
CValidationState & | state, | ||
bool | fCheckDuplicateInputs = true |
||
) |
Transaction validation functions.
Context-independent validity checks
Definition at line 506 of file validation.cpp.
int32_t ComputeBlockVersion | ( | const CBlockIndex * | pindexPrev, |
const Consensus::Params & | params | ||
) |
Determine what nVersion a new block should use.
Definition at line 1712 of file validation.cpp.
bool ConnectBlock | ( | const CBlock & | block, |
CValidationState & | state, | ||
CBlockIndex * | pindex, | ||
CCoinsViewCache & | coins, | ||
const CChainParams & | chainparams, | ||
bool | fJustCheck = false |
||
) |
Apply the effects of this block (with given index) on the UTXO set represented by coins.
Validity checks that depend on the UTXO set are also done; ConnectBlock() can fail if those validity checks fail (among other reasons).
Definition at line 1762 of file validation.cpp.
bool ContextualCheckBlock | ( | const CBlock & | block, |
CValidationState & | state, | ||
const CBlockIndex * | pindexPrev | ||
) |
bool ContextualCheckBlockHeader | ( | const CBlockHeader & | block, |
CValidationState & | state, | ||
const CBlockIndex * | pindexPrev, | ||
int64_t | nAdjustedTime | ||
) |
Context-dependent validity checks.
By "context", we mean only the previous block headers, but not the UTXO set; UTXO-related validity checks are done in ConnectBlock().
Definition at line 3006 of file validation.cpp.
bool DisconnectBlock | ( | const CBlock & | block, |
CValidationState & | state, | ||
const CBlockIndex * | pindex, | ||
CCoinsViewCache & | coins, | ||
bool * | pfClean = NULL |
||
) |
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 1609 of file validation.cpp.
void DumpMempool | ( | ) |
Dump the mempool to disk.
Definition at line 4323 of file validation.cpp.
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.
[out] | setFilesToPrune | The set of file indices that can be unlinked will be returned |
Definition at line 3443 of file validation.cpp.
CBlockIndex* FindForkInGlobalIndex | ( | const CChain & | chain, |
const CBlockLocator & | locator | ||
) |
Find the last common block between the parameter chain and a locator.
Definition at line 205 of file validation.cpp.
void FlushStateToDisk | ( | ) |
Flush all state, indexes and buffers to disk.
Definition at line 2122 of file validation.cpp.
std::string FormatStateMessage | ( | const CValidationState & | state | ) |
Convert CValidationState to a human-readable message for logging.
Definition at line 567 of file validation.cpp.
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 2977 of file validation.cpp.
CBlockFileInfo* GetBlockFileInfo | ( | size_t | n | ) |
Get block file info entry for one block file.
Definition at line 4236 of file validation.cpp.
boost::filesystem::path GetBlockPosFilename | ( | const CDiskBlockPos & | pos, |
const char * | prefix | ||
) |
Translation to a filesystem path.
Definition at line 3532 of file validation.cpp.
CAmount GetBlockSubsidy | ( | int | nHeight, |
const Consensus::Params & | consensusParams | ||
) |
Definition at line 1200 of file validation.cpp.
unsigned int GetLegacySigOpCount | ( | const CTransaction & | tx | ) |
Count ECDSA signature operations the old-fashioned (pre-0.6) way.
Definition at line 454 of file validation.cpp.
unsigned int GetP2SHSigOpCount | ( | const CTransaction & | tx, |
const CCoinsViewCache & | mapInputs | ||
) |
Count ECDSA signature operations in pay-to-script-hash inputs.
[in] | mapInputs | Map of previous transactions that have outputs we're spending |
Definition at line 468 of file validation.cpp.
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 1386 of file validation.cpp.
bool GetTransaction | ( | const uint256 & | hash, |
CTransactionRef & | txOut, | ||
const Consensus::Params & | consensusParams, | ||
uint256 & | hashBlock, | ||
bool | fAllowSlow | ||
) |
Retrieve a transaction (from memory pool, or from disk, if possible)
Retrieve a transaction (from memory pool, or from disk, if possible)
Definition at line 1053 of file validation.cpp.
int64_t GetTransactionSigOpCost | ( | const CTransaction & | tx, |
const CCoinsViewCache & | inputs, | ||
int | flags | ||
) |
Compute total signature operation cost of a transaction.
[in] | tx | Transaction for which we are computing the cost |
[in] | inputs | Map of previous transactions that have outputs we're spending |
[out] | flags | Script verification flags |
Definition at line 483 of file validation.cpp.
std::string GetWarnings | ( | const std::string & | strFor | ) |
Format a string that describes several potential problems detected by the core.
strFor can have three values:
Definition at line 51 of file warnings.cpp.
double GuessVerificationProgress | ( | const ChainTxData & | data, |
CBlockIndex * | pindex | ||
) |
Guess verification progress (as a fraction between 0.0=genesis and 1.0=current tip).
Guess verification progress (as a fraction between 0.0=genesis and 1.0=current tip).
Definition at line 4371 of file validation.cpp.
bool InitBlockIndex | ( | const CChainParams & | chainparams | ) |
Initialize a new block tree database + block data on disk.
Definition at line 3891 of file validation.cpp.
CBlockIndex* InsertBlockIndex | ( | uint256 | hash | ) |
Create a new block index entry for a given block hash.
Definition at line 3537 of file validation.cpp.
bool InvalidateBlock | ( | CValidationState & | state, |
const CChainParams & | chainparams, | ||
CBlockIndex * | pindex | ||
) |
Mark a block as invalid.
Definition at line 2608 of file validation.cpp.
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 237 of file validation.cpp.
bool IsInitialBlockDownload | ( | ) |
Check whether we are doing an initial block download (synchronizing from disk or network)
Definition at line 1213 of file validation.cpp.
bool IsWitnessEnabled | ( | const CBlockIndex * | pindexPrev, |
const Consensus::Params & | params | ||
) |
Check whether witness commitments are required for block.
Definition at line 2942 of file validation.cpp.
bool LoadBlockIndex | ( | const CChainParams & | chainparams | ) |
Load the block tree and coins database from disk.
Definition at line 3883 of file validation.cpp.
bool LoadExternalBlockFile | ( | const CChainParams & | chainparams, |
FILE * | fileIn, | ||
CDiskBlockPos * | dbp = NULL |
||
) |
Import blocks from an external file.
Definition at line 3929 of file validation.cpp.
bool LoadMempool | ( | ) |
Load the mempool from disk.
Definition at line 4257 of file validation.cpp.
FILE* OpenBlockFile | ( | const CDiskBlockPos & | pos, |
bool | fReadOnly = false |
||
) |
Open a block file (blk?????.dat)
Definition at line 3524 of file validation.cpp.
FILE* OpenUndoFile | ( | const CDiskBlockPos & | pos, |
bool | fReadOnly = false |
||
) |
Open an undo file (rev?????.dat)
Definition at line 3528 of file validation.cpp.
bool PreciousBlock | ( | CValidationState & | state, |
const CChainParams & | params, | ||
CBlockIndex * | pindex | ||
) |
Mark a block as precious and reorganize.
Definition at line 2579 of file validation.cpp.
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.
[in] | pblock | The block we want to process. |
[in] | fForceProcessing | Process this block even if unrequested; used for non-network block sources and whitelisted peers. |
[out] | fNewBlock | A boolean which is set to indicate if the block was first received via this call |
Definition at line 3294 of file validation.cpp.
bool ProcessNewBlockHeaders | ( | const std::vector< CBlockHeader > & | block, |
CValidationState & | state, | ||
const CChainParams & | chainparams, | ||
const CBlockIndex ** | ppindex = NULL |
||
) |
Process incoming block headers.
Call without cs_main held.
[in] | block | The block headers themselves |
[out] | state | This may be set to an Error state if any error occurred processing them |
[in] | chainparams | The params for the chain we want to connect to |
[out] | ppindex | If set, the pointer will be set to point to the last new block index object for the given headers |
Definition at line 3184 of file validation.cpp.
void PruneAndFlush | ( | ) |
Prune block files and flush state to disk.
Definition at line 2127 of file validation.cpp.
void PruneBlockFilesManual | ( | int | nPruneUpToHeight | ) |
Prune block files up to a given height.
Definition at line 3436 of file validation.cpp.
void PruneOneBlockFile | ( | const int | fileNumber | ) |
Mark one block file as pruned.
Definition at line 3369 of file validation.cpp.
bool ReadBlockFromDisk | ( | CBlock & | block, |
const CBlockIndex * | pindex, | ||
const Consensus::Params & | consensusParams, | ||
bool | fCheckPOW = true |
||
) |
Definition at line 1190 of file validation.cpp.
bool ReadBlockFromDisk | ( | CBlock & | block, |
const CDiskBlockPos & | pos, | ||
const Consensus::Params & | consensusParams, | ||
bool | fCheckPOW = true |
||
) |
bool ReadBlockHeaderFromDisk | ( | CBlockHeader & | block, |
const CBlockIndex * | pindex, | ||
const Consensus::Params & | consensusParams, | ||
bool | fCheckPOW = true |
||
) |
bool ResetBlockFailureFlags | ( | CBlockIndex * | pindex | ) |
Remove invalidity status from a block and its descendants.
Definition at line 2648 of file validation.cpp.
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 3770 of file validation.cpp.
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 360 of file validation.cpp.
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 3326 of file validation.cpp.
bool TestLockPointValidity | ( | const LockPoints * | lp | ) |
Test whether the LockPoints height and time are still valid on the current chain.
Definition at line 365 of file validation.cpp.
void ThreadScriptCheck | ( | ) |
Run an instance of the script checking thread.
Definition at line 1704 of file validation.cpp.
void UnlinkPrunedFiles | ( | const std::set< int > & | setFilesToPrune | ) |
Actually unlink the specified files.
Definition at line 3403 of file validation.cpp.
void UnloadBlockIndex | ( | ) |
Unload database information.
Definition at line 3857 of file validation.cpp.
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 1371 of file validation.cpp.
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 2965 of file validation.cpp.
ThresholdState VersionBitsTipState | ( | const Consensus::Params & | params, |
Consensus::DeploymentPos | pos | ||
) |
Get the BIP9 state for a given deployment at the current tip.
Definition at line 4243 of file validation.cpp.
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 4249 of file validation.cpp.
bool WriteBlockToDisk | ( | const CBlock & | block, |
CDiskBlockPos & | pos, | ||
const CMessageHeader::MessageStartChars & | messageStart | ||
) |
Functions for disk access for blocks.
Definition at line 1125 of file validation.cpp.
|
extern |
The currently-connected chain of blocks (protected by cs_main).
Definition at line 64 of file validation.cpp.
|
extern |
Constant stuff for coinbase transactions we create:
Definition at line 99 of file validation.cpp.
|
extern |
Global state.
Definition at line 61 of file validation.cpp.
|
extern |
Definition at line 66 of file validation.cpp.
|
extern |
Definition at line 67 of file validation.cpp.
|
extern |
Definition at line 80 of file validation.cpp.
|
extern |
Definition at line 76 of file validation.cpp.
|
extern |
Definition at line 77 of file validation.cpp.
|
extern |
Definition at line 82 of file validation.cpp.
|
extern |
Pruning-related variables and constants.
True if any block files have ever been pruned.
Definition at line 72 of file validation.cpp.
|
extern |
|
extern |
Definition at line 74 of file validation.cpp.
|
extern |
True if we're running in -prune mode.
Definition at line 73 of file validation.cpp.
|
extern |
Definition at line 70 of file validation.cpp.
|
extern |
Definition at line 75 of file validation.cpp.
|
extern |
Definition at line 71 of file validation.cpp.
|
extern |
Block hash whose ancestors we will assume to have valid scripts without checking them.
Definition at line 84 of file validation.cpp.
|
extern |
Definition at line 63 of file validation.cpp.
|
extern |
Absolute maximum transaction fee (in satoshis) used by wallet and mempool (rejects high fee in sendrawtransaction)
Definition at line 87 of file validation.cpp.
|
extern |
|
extern |
A fee rate smaller than this is considered zero fee (for relaying, mining and transaction creation)
Definition at line 86 of file validation.cpp.
|
extern |
Definition at line 78 of file validation.cpp.
|
extern |
If the tip is older than this (in seconds), the node is considered to be in initial block download.
Definition at line 81 of file validation.cpp.
|
extern |
Number of MiB of block files that we're trying to stay below.
Definition at line 79 of file validation.cpp.
|
extern |
Definition at line 68 of file validation.cpp.
|
extern |
Global variable that points to the active block tree (protected by cs_main)
Definition at line 224 of file validation.cpp.
|
extern |
Global variable that points to the active CCoinsView (protected by cs_main)
Definition at line 223 of file validation.cpp.
|
extern |
Best header we've seen so far (used for getheaders queries' starting points).
Definition at line 65 of file validation.cpp.
|
extern |
Definition at line 101 of file validation.cpp.
|
extern |
Definition at line 1710 of file validation.cpp.