BSHA3  0.17.99
P2P Blockchain, based on Bitcoin
validation.h
Go to the documentation of this file.
1 // Copyright (c) 2009-2010 Satoshi Nakamoto
2 // Copyright (c) 2009-2018 The Bitcoin Core developers
3 // Distributed under the MIT software license, see the accompanying
4 // file COPYING or http://www.opensource.org/licenses/mit-license.php.
5 
6 #ifndef BITCOIN_VALIDATION_H
7 #define BITCOIN_VALIDATION_H
8 
9 #if defined(HAVE_CONFIG_H)
10 #include <config/bitcoin-config.h>
11 #endif
12 
13 #include <amount.h>
14 #include <coins.h>
15 #include <fs.h>
16 #include <protocol.h> // For CMessageHeader::MessageStartChars
17 #include <policy/feerate.h>
18 #include <script/script_error.h>
19 #include <sync.h>
20 #include <versionbits.h>
21 
22 #include <algorithm>
23 #include <exception>
24 #include <map>
25 #include <memory>
26 #include <set>
27 #include <stdint.h>
28 #include <string>
29 #include <utility>
30 #include <vector>
31 
32 #include <atomic>
33 
34 class CBlockIndex;
35 class CBlockTreeDB;
36 class CChainParams;
37 class CCoinsViewDB;
38 class CInv;
39 class CConnman;
40 class CScriptCheck;
42 class CTxMemPool;
43 class CValidationState;
44 struct ChainTxData;
45 
47 struct LockPoints;
48 
50 static const bool DEFAULT_WHITELISTRELAY = true;
52 static const bool DEFAULT_WHITELISTFORCERELAY = true;
54 static const unsigned int DEFAULT_MIN_RELAY_TX_FEE = 1000;
56 static const CAmount DEFAULT_TRANSACTION_MAXFEE = COIN / 10;
58 static const CAmount HIGH_TX_FEE_PER_KB = COIN / 100;
60 static const CAmount HIGH_MAX_TX_FEE = 100 * HIGH_TX_FEE_PER_KB;
62 static const unsigned int DEFAULT_ANCESTOR_LIMIT = 25;
64 static const unsigned int DEFAULT_ANCESTOR_SIZE_LIMIT = 101;
66 static const unsigned int DEFAULT_DESCENDANT_LIMIT = 25;
68 static const unsigned int DEFAULT_DESCENDANT_SIZE_LIMIT = 101;
70 static const unsigned int DEFAULT_MEMPOOL_EXPIRY = 336;
72 static const unsigned int MAX_DISCONNECTED_TX_POOL_SIZE = 20000;
74 static const unsigned int MAX_BLOCKFILE_SIZE = 0x8000000; // 128 MiB
76 static const unsigned int BLOCKFILE_CHUNK_SIZE = 0x1000000; // 16 MiB
78 static const unsigned int UNDOFILE_CHUNK_SIZE = 0x100000; // 1 MiB
79 
81 static const int MAX_SCRIPTCHECK_THREADS = 16;
83 static const int DEFAULT_SCRIPTCHECK_THREADS = 0;
85 static const int MAX_BLOCKS_IN_TRANSIT_PER_PEER = 16;
87 static const unsigned int BLOCK_STALLING_TIMEOUT = 2;
90 static const unsigned int MAX_HEADERS_RESULTS = 2000;
93 static const int MAX_CMPCTBLOCK_DEPTH = 5;
95 static const int MAX_BLOCKTXN_DEPTH = 10;
100 static const unsigned int BLOCK_DOWNLOAD_WINDOW = 1024;
102 static const unsigned int DATABASE_WRITE_INTERVAL = 60 * 60;
104 static const unsigned int DATABASE_FLUSH_INTERVAL = 24 * 60 * 60;
106 static const unsigned int MAX_REJECT_MESSAGE_LENGTH = 111;
108 static const int64_t BLOCK_DOWNLOAD_TIMEOUT_BASE = 1000000;
110 static const int64_t BLOCK_DOWNLOAD_TIMEOUT_PER_PEER = 500000;
111 
112 static const int64_t DEFAULT_MAX_TIP_AGE = 24 * 60 * 60;
114 static const int64_t MAX_FEE_ESTIMATION_TIP_AGE = 3 * 60 * 60;
115 
117 static const bool DEFAULT_PERMIT_BAREMULTISIG = true;
118 static const bool DEFAULT_CHECKPOINTS_ENABLED = true;
119 static const bool DEFAULT_TXINDEX = false;
120 static const unsigned int DEFAULT_BANSCORE_THRESHOLD = 100;
122 static const bool DEFAULT_PERSIST_MEMPOOL = true;
124 static const bool DEFAULT_ENABLE_REPLACEMENT = true;
126 static const bool DEFAULT_FEEFILTER = true;
127 
129 static const unsigned int MAX_BLOCKS_TO_ANNOUNCE = 8;
130 
132 static const int MAX_UNCONNECTING_HEADERS = 10;
133 
134 static const bool DEFAULT_PEERBLOOMFILTERS = true;
135 
137 static const int DEFAULT_STOPATHEIGHT = 0;
138 
140 {
141  size_t operator()(const uint256& hash) const { return hash.GetCheapHash(); }
142 };
143 
144 extern CScript COINBASE_FLAGS;
147 extern CTxMemPool mempool;
148 extern std::atomic_bool g_is_mempool_loaded;
149 typedef std::unordered_map<uint256, CBlockIndex*, BlockHasher> BlockMap;
150 extern BlockMap& mapBlockIndex;
151 extern uint64_t nLastBlockTx;
152 extern uint64_t nLastBlockWeight;
153 extern const std::string strMessageMagic;
155 extern std::condition_variable g_best_block_cv;
156 extern uint256 g_best_block;
157 extern std::atomic_bool fImporting;
158 extern std::atomic_bool fReindex;
159 extern int nScriptCheckThreads;
160 extern bool fIsBareMultisigStd;
161 extern bool fRequireStandard;
162 extern bool fCheckBlockIndex;
163 extern bool fCheckpointsEnabled;
164 extern size_t nCoinCacheUsage;
166 extern CFeeRate minRelayTxFee;
168 extern CAmount maxTxFee;
170 extern int64_t nMaxTipAge;
171 extern bool fEnableReplacement;
172 
174 extern uint256 hashAssumeValid;
175 
178 
181 
183 static const uint64_t nMinDiskSpace = 52428800;
184 
187 extern bool fHavePruned;
189 extern bool fPruneMode;
191 extern uint64_t nPruneTarget;
193 static const unsigned int MIN_BLOCKS_TO_KEEP = 288;
195 static const unsigned int NODE_NETWORK_LIMITED_MIN_BLOCKS = 288;
196 
197 static const signed int DEFAULT_CHECKBLOCKS = 6;
198 static const unsigned int DEFAULT_CHECKLEVEL = 3;
199 
200 // Require that user allocate at least 550MB for block & undo files (blk???.dat and rev???.dat)
201 // At 1MB per block, 288 blocks = 288MB.
202 // Add 15% for Undo data = 331MB
203 // Add 20% for Orphan block rate = 397MB
204 // We want the low water mark after pruning to be at least 397 MB and since we prune in
205 // full block file chunks, we need the high water mark which triggers the prune to be
206 // one 128MB block file + added 15% undo data = 147MB greater for a total of 545MB
207 // Setting the target to > than 550MB will make it likely we can respect the target.
208 static const uint64_t MIN_DISK_SPACE_FOR_BLOCK_FILES = 550 * 1024 * 1024;
209 
230 bool ProcessNewBlock(const CChainParams& chainparams, const std::shared_ptr<const CBlock> pblock, bool fForceProcessing, bool* fNewBlock) LOCKS_EXCLUDED(cs_main);
231 
244 bool ProcessNewBlockHeaders(const std::vector<CBlockHeader>& block, CValidationState& state, const CChainParams& chainparams, const CBlockIndex** ppindex = nullptr, CBlockHeader* first_invalid = nullptr) LOCKS_EXCLUDED(cs_main);
245 
247 bool CheckDiskSpace(uint64_t nAdditionalBytes = 0, bool blocks_dir = false);
249 FILE* OpenBlockFile(const CDiskBlockPos &pos, bool fReadOnly = false);
251 fs::path GetBlockPosFilename(const CDiskBlockPos &pos, const char *prefix);
253 bool LoadExternalBlockFile(const CChainParams& chainparams, FILE* fileIn, CDiskBlockPos *dbp = nullptr);
255 bool LoadGenesisBlock(const CChainParams& chainparams);
262 void UnloadBlockIndex();
264 void ThreadScriptCheck();
268 bool GetTransaction(const uint256& hash, CTransactionRef& tx, const Consensus::Params& params, uint256& hashBlock, bool fAllowSlow = false, CBlockIndex* blockIndex = nullptr);
275 bool ActivateBestChain(CValidationState& state, const CChainParams& chainparams, std::shared_ptr<const CBlock> pblock = std::shared_ptr<const CBlock>());
276 CAmount GetBlockSubsidy(int nHeight, const Consensus::Params& consensusParams);
277 
279 double GuessVerificationProgress(const ChainTxData& data, const CBlockIndex* pindex);
280 
282 uint64_t CalculateCurrentUsage();
283 
287 void PruneOneBlockFile(const int fileNumber);
288 
292 void UnlinkPrunedFiles(const std::set<int>& setFilesToPrune);
293 
295 void FlushStateToDisk();
297 void PruneAndFlush();
299 void PruneBlockFilesManual(int nManualPruneHeight);
300 
303 bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransactionRef &tx,
304  bool* pfMissingInputs, std::list<CTransactionRef>* plTxnReplaced,
305  bool bypass_limits, const CAmount nAbsurdFee, bool test_accept=false) EXCLUSIVE_LOCKS_REQUIRED(cs_main);
306 
308 std::string FormatStateMessage(const CValidationState &state);
309 
312 
315 
318 
319 
321 void UpdateCoins(const CTransaction& tx, CCoinsViewCache& inputs, int nHeight);
322 
333 
338 
350 bool CheckSequenceLocks(const CTxMemPool& pool, const CTransaction& tx, int flags, LockPoints* lp = nullptr, bool useExistingLockPoints = false) EXCLUSIVE_LOCKS_REQUIRED(cs_main);
351 
357 {
358 private:
361  unsigned int nIn;
362  unsigned int nFlags;
366 
367 public:
368  CScriptCheck(): ptxTo(nullptr), nIn(0), nFlags(0), cacheStore(false), error(SCRIPT_ERR_UNKNOWN_ERROR) {}
369  CScriptCheck(const CTxOut& outIn, const CTransaction& txToIn, unsigned int nInIn, unsigned int nFlagsIn, bool cacheIn, PrecomputedTransactionData* txdataIn) :
370  m_tx_out(outIn), ptxTo(&txToIn), nIn(nInIn), nFlags(nFlagsIn), cacheStore(cacheIn), error(SCRIPT_ERR_UNKNOWN_ERROR), txdata(txdataIn) { }
371 
372  bool operator()();
373 
374  void swap(CScriptCheck &check) {
375  std::swap(ptxTo, check.ptxTo);
376  std::swap(m_tx_out, check.m_tx_out);
377  std::swap(nIn, check.nIn);
378  std::swap(nFlags, check.nFlags);
379  std::swap(cacheStore, check.cacheStore);
380  std::swap(error, check.error);
381  std::swap(txdata, check.txdata);
382  }
383 
384  ScriptError GetScriptError() const { return error; }
385 };
386 
389 
390 
392 bool ReadBlockFromDisk(CBlock& block, const CDiskBlockPos& pos, const Consensus::Params& consensusParams);
393 bool ReadBlockFromDisk(CBlock& block, const CBlockIndex* pindex, const Consensus::Params& consensusParams);
394 bool ReadRawBlockFromDisk(std::vector<uint8_t>& block, const CDiskBlockPos& pos, const CMessageHeader::MessageStartChars& message_start);
395 bool ReadRawBlockFromDisk(std::vector<uint8_t>& block, const CBlockIndex* pindex, const CMessageHeader::MessageStartChars& message_start);
396 
400 bool CheckBlock(const CBlock& block, CValidationState& state, const Consensus::Params& consensusParams, bool fCheckPOW = true, bool fCheckMerkleRoot = true);
401 
403 bool TestBlockValidity(CValidationState& state, const CChainParams& chainparams, const CBlock& block, CBlockIndex* pindexPrev, bool fCheckPOW = true, bool fCheckMerkleRoot = true) EXCLUSIVE_LOCKS_REQUIRED(cs_main);
404 
406 bool IsWitnessEnabled(const CBlockIndex* pindexPrev, const Consensus::Params& params);
407 
409 bool IsNullDummyEnabled(const CBlockIndex* pindexPrev, const Consensus::Params& params);
410 
412 bool RewindBlockIndex(const CChainParams& params);
413 
415 void UpdateUncommittedBlockStructures(CBlock& block, const CBlockIndex* pindexPrev, const Consensus::Params& consensusParams);
416 
418 std::vector<unsigned char> GenerateCoinbaseCommitment(CBlock& block, const CBlockIndex* pindexPrev, const Consensus::Params& consensusParams);
419 
421 class CVerifyDB {
422 public:
423  CVerifyDB();
424  ~CVerifyDB();
425  bool VerifyDB(const CChainParams& chainparams, CCoinsView *coinsview, int nCheckLevel, int nCheckDepth);
426 };
427 
429 bool ReplayBlocks(const CChainParams& params, CCoinsView* view);
430 
432 {
434  BlockMap::const_iterator it = mapBlockIndex.find(hash);
435  return it == mapBlockIndex.end() ? nullptr : it->second;
436 }
437 
440 
446 bool PreciousBlock(CValidationState& state, const CChainParams& params, CBlockIndex *pindex) LOCKS_EXCLUDED(cs_main);
447 
450 
453 
455 extern CChain& chainActive;
456 
458 extern std::unique_ptr<CCoinsViewDB> pcoinsdbview;
459 
461 extern std::unique_ptr<CCoinsViewCache> pcoinsTip;
462 
464 extern std::unique_ptr<CBlockTreeDB> pblocktree;
465 
471 int GetSpendHeight(const CCoinsViewCache& inputs);
472 
474 
478 int32_t ComputeBlockVersion(const CBlockIndex* pindexPrev, const Consensus::Params& params);
479 
484 static const unsigned int REJECT_INTERNAL = 0x100;
486 static const unsigned int REJECT_HIGHFEE = 0x100;
487 
490 
492 bool DumpMempool();
493 
495 bool LoadMempool();
496 
498 inline bool IsBlockPruned(const CBlockIndex* pblockindex)
499 {
500  return (fHavePruned && !(pblockindex->nStatus & BLOCK_HAVE_DATA) && pblockindex->nTx > 0);
501 }
502 
503 #endif // BITCOIN_VALIDATION_H
bool ProcessNewBlock(const CChainParams &chainparams, const std::shared_ptr< const CBlock > pblock, bool fForceProcessing, bool *fNewBlock) LOCKS_EXCLUDED(cs_main)
Process an incoming block.
CTxMemPool mempool
void FlushStateToDisk()
Flush all state, indexes and buffers to disk.
bool CheckFinalTx(const CTransaction &tx, int flags=-1) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
Transaction validation functions.
Definition: validation.cpp:315
size_t nCoinCacheUsage
Definition: validation.cpp:233
int64_t nMaxTipAge
If the tip is older than this (in seconds), the node is considered to be in initial block download...
Definition: validation.cpp:235
bool AcceptToMemoryPool(CTxMemPool &pool, CValidationState &state, const CTransactionRef &tx, bool *pfMissingInputs, std::list< CTransactionRef > *plTxnReplaced, bool bypass_limits, const CAmount nAbsurdFee, bool test_accept=false) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
(try to) add transaction to memory pool plTxnReplaced will be appended to with all transactions repla...
Definition: validation.cpp:986
bool IsNullDummyEnabled(const CBlockIndex *pindexPrev, const Consensus::Params &params)
Check whether NULLDUMMY (BIP 147) has activated.
bool LoadExternalBlockFile(const CChainParams &chainparams, FILE *fileIn, CDiskBlockPos *dbp=nullptr)
Import blocks from an external file.
enum ScriptError_t ScriptError
Describes a place in the block chain to another node such that if the other node doesn&#39;t have the sam...
Definition: block.h:128
void PruneOneBlockFile(const int fileNumber)
Mark one block file as pruned.
uint32_t nStatus
Verification status of this block. See enum BlockStatus.
Definition: chain.h:207
std::atomic_bool g_is_mempool_loaded
Definition: validation.cpp:246
void swap(CScriptCheck &check)
Definition: validation.h:374
Definition: block.h:74
An in-memory indexed chain of blocks.
Definition: chain.h:434
uint64_t CalculateCurrentUsage()
Calculate the amount of disk space the block & undo files currently use.
unsigned int nFlags
Definition: validation.h:362
void PruneBlockFilesManual(int nManualPruneHeight)
Prune block files up to a given height.
inv message data
Definition: protocol.h:385
CBlockIndex * pindexBestHeader
Best header we&#39;ve seen so far (used for getheaders queries&#39; starting points).
Definition: validation.cpp:220
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.
const char * prefix
Definition: rest.cpp:581
CBlockPolicyEstimator feeEstimator
Definition: validation.cpp:244
bool CheckSequenceLocks(const CTxMemPool &pool, const CTransaction &tx, int flags, LockPoints *lp=nullptr, bool useExistingLockPoints=false) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
Check if transaction will be BIP 68 final in the next block to be created.
Definition: validation.cpp:365
bool InvalidateBlock(CValidationState &state, const CChainParams &chainparams, CBlockIndex *pindex) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
Mark a block as invalid.
bool LoadChainTip(const CChainParams &chainparams) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
Update the chain tip based on database information.
BlockMap & mapBlockIndex
Definition: validation.cpp:218
CChainParams defines various tweakable parameters of a given instance of the Bitcoin system...
Definition: chainparams.h:47
ScriptError error
Definition: validation.h:364
ThresholdState
Definition: versionbits.h:20
bool TestBlockValidity(CValidationState &state, const CChainParams &chainparams, const CBlock &block, CBlockIndex *pindexPrev, bool fCheckPOW=true, bool fCheckMerkleRoot=true) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
Check a block is completely valid from start to finish (only works on top of our current best block) ...
bool LoadMempool()
Load the mempool from disk.
void ResetBlockFailureFlags(CBlockIndex *pindex) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
Remove invalidity status from a block and its descendants.
double GuessVerificationProgress(const ChainTxData &data, const CBlockIndex *pindex)
Guess verification progress (as a fraction between 0.0=genesis and 1.0=current tip).
bool cacheStore
Definition: validation.h:363
std::shared_ptr< const CTransaction > CTransactionRef
Definition: transaction.h:402
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.
CTxOut m_tx_out
Definition: validation.h:359
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...
bool PreciousBlock(CValidationState &state, const CChainParams &params, CBlockIndex *pindex) LOCKS_EXCLUDED(cs_main)
Mark a block as precious and reorganize.
bool fEnableReplacement
Definition: validation.cpp:236
CChain & chainActive
The currently-connected chain of blocks (protected by cs_main).
Definition: validation.cpp:219
CScriptCheck(const CTxOut &outIn, const CTransaction &txToIn, unsigned int nInIn, unsigned int nFlagsIn, bool cacheIn, PrecomputedTransactionData *txdataIn)
Definition: validation.h:369
CCriticalSection cs_main
Definition: validation.cpp:216
int64_t CAmount
Amount in satoshis (Can be negative)
Definition: amount.h:12
#define AssertLockHeld(cs)
Definition: sync.h:70
bool LoadBlockIndex(const CChainParams &chainparams) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
Load the block tree and coins database from disk, initializing state if we&#39;re running with -reindex...
bool ReadBlockFromDisk(CBlock &block, const CDiskBlockPos &pos, const Consensus::Params &consensusParams)
Functions for disk access for blocks.
void UpdateUncommittedBlockStructures(CBlock &block, const CBlockIndex *pindexPrev, const Consensus::Params &consensusParams)
Update uncommitted block structures (currently: only the witness reserved value). ...
Access to the block database (blocks/index/)
Definition: txdb.h:86
Abstract view on the open txout dataset.
Definition: coins.h:145
bool GetTransaction(const uint256 &hash, CTransactionRef &tx, const Consensus::Params &params, uint256 &hashBlock, bool fAllowSlow=false, CBlockIndex *blockIndex=nullptr)
Retrieve a transaction (from memory pool, or from disk, if possible)
Definition: validation.cpp:998
DeploymentPos
Definition: params.h:16
bool fHavePruned
Pruning-related variables and constants.
Definition: validation.cpp:227
void InitScriptExecutionCache()
Initializes the script-execution cache.
The BlockPolicyEstimator is used for estimating the feerate needed for a transaction to be included i...
Definition: fees.h:136
fs::path GetBlockPosFilename(const CDiskBlockPos &pos, const char *prefix)
Translation to a filesystem path.
RAII wrapper for VerifyDB: Verify consistency of the block and coin databases.
Definition: validation.h:421
bool TestLockPointValidity(const LockPoints *lp) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
Test whether the LockPoints height and time are still valid on the current chain. ...
Definition: validation.cpp:347
Holds various statistics on transactions within a chain.
Definition: chainparams.h:34
arith_uint256 nMinimumChainWork
Minimum work we will assume exists on some valid chain.
Definition: validation.cpp:239
Definition: net.h:115
An output of a transaction.
Definition: transaction.h:131
ThresholdState VersionBitsTipState(const Consensus::Params &params, Consensus::DeploymentPos pos)
Get the BIP9 state for a given deployment at the current tip.
std::atomic_bool fImporting
Parameters that influence chain consensus.
Definition: params.h:40
std::string FormatStateMessage(const CValidationState &state)
Convert CValidationState to a human-readable message for logging.
Definition: validation.cpp:453
bool ReplayBlocks(const CChainParams &params, CCoinsView *view)
Replay blocks that aren&#39;t fully applied to the database.
CAmount GetBlockSubsidy(int nHeight, const Consensus::Params &consensusParams)
bool CheckDiskSpace(uint64_t nAdditionalBytes=0, bool blocks_dir=false)
Check whether enough disk space is available for an incoming block.
int32_t ComputeBlockVersion(const CBlockIndex *pindexPrev, const Consensus::Params &params)
Determine what nVersion a new block should use.
size_t operator()(const uint256 &hash) const
Definition: validation.h:141
256-bit unsigned big integer.
unsigned char MessageStartChars[MESSAGE_START_SIZE]
Definition: protocol.h:38
uint64_t nPruneTarget
Number of MiB of block files that we&#39;re trying to stay below.
Definition: validation.cpp:234
uint256 g_best_block
Definition: validation.cpp:223
Closure representing one script verification Note that this stores references to the spending transac...
Definition: validation.h:356
CFeeRate minRelayTxFee
A fee rate smaller than this is considered zero fee (for relaying, mining and transaction creation) ...
Definition: validation.cpp:241
std::condition_variable g_best_block_cv
Definition: validation.cpp:222
std::atomic_bool fReindex
bool RewindBlockIndex(const CChainParams &params)
When there are blocks in the active chain with missing data, rewind the chainstate and remove them fr...
Capture information about block/transaction validation.
Definition: validation.h:26
256-bit opaque blob.
Definition: uint256.h:122
bool ProcessNewBlockHeaders(const std::vector< CBlockHeader > &block, CValidationState &state, const CChainParams &chainparams, const CBlockIndex **ppindex=nullptr, CBlockHeader *first_invalid=nullptr) LOCKS_EXCLUDED(cs_main)
Process incoming block headers.
const CTransaction * ptxTo
Definition: validation.h:360
uint64_t nLastBlockWeight
Definition: miner.cpp:42
#define EXCLUSIVE_LOCKS_REQUIRED(...)
Definition: threadsafety.h:51
CTxMemPool stores valid-according-to-the-current-best-chain transactions that may be included in the ...
Definition: txmempool.h:441
FILE * OpenBlockFile(const CDiskBlockPos &pos, bool fReadOnly=false)
Open a block file (blk?????.dat)
#define LOCKS_EXCLUDED(...)
Definition: threadsafety.h:50
bool fRequireStandard
Definition: validation.cpp:230
bool IsWitnessEnabled(const CBlockIndex *pindexPrev, const Consensus::Params &params)
Check whether witness commitments are required for block.
The block chain is a tree shaped structure starting with the genesis block at the root...
Definition: chain.h:170
const CChainParams & Params()
Return the currently selected parameters.
bool IsBlockPruned(const CBlockIndex *pblockindex)
Check whether the block associated with this index entry is pruned or not.
Definition: validation.h:498
Serialized script, used inside transaction inputs and outputs.
Definition: script.h:384
CCoinsView backed by the coin database (chainstate/)
Definition: txdb.h:44
CAmount maxTxFee
Absolute maximum transaction fee (in satoshis) used by wallet and mempool (rejects high fee in sendra...
Definition: validation.cpp:242
void UpdateCoins(const CTransaction &tx, CCoinsViewCache &inputs, int nHeight)
Apply the effects of this transaction on the UTXO set represented by view.
uint256 hashAssumeValid
Block hash whose ancestors we will assume to have valid scripts without checking them.
Definition: validation.cpp:238
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&#39;t call for mined blocks...
std::unique_ptr< CCoinsViewDB > pcoinsdbview
Global variable that points to the coins database (protected by cs_main)
Definition: validation.cpp:297
void PruneAndFlush()
Prune block files and flush state to disk.
Fee rate in satoshis per kilobyte: CAmount / kB.
Definition: feerate.h:19
void ThreadScriptCheck()
Run an instance of the script checking thread.
bool fIsBareMultisigStd
Definition: validation.cpp:229
bool error(const char *fmt, const Args &... args)
Definition: util.h:59
bool IsInitialBlockDownload()
Check whether we are doing an initial block download (synchronizing from disk or network) ...
bool ReadRawBlockFromDisk(std::vector< uint8_t > &block, const CDiskBlockPos &pos, const CMessageHeader::MessageStartChars &message_start)
CBlockIndex * FindForkInGlobalIndex(const CChain &chain, const CBlockLocator &locator) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
Find the last common block between the parameter chain and a locator.
Definition: validation.cpp:278
unsigned int nIn
Definition: validation.h:361
CScript COINBASE_FLAGS
Constant stuff for coinbase transactions we create:
Definition: validation.cpp:249
int flags
Definition: bsha3-tx.cpp:509
int nScriptCheckThreads
Definition: validation.cpp:224
The basic transaction that is broadcasted on the network and contained in blocks. ...
Definition: transaction.h:264
std::unordered_map< uint256, CBlockIndex *, BlockHasher > BlockMap
Definition: validation.h:149
bool fPruneMode
True if we&#39;re running in -prune mode.
Definition: validation.cpp:228
CCoinsView that adds a memory cache for transactions to another CCoinsView.
Definition: coins.h:201
full block available in blk*.dat
Definition: chain.h:154
int GetSpendHeight(const CCoinsViewCache &inputs)
Return the spend height, which is one more than the inputs.GetBestBlock().
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 t...
uint64_t GetCheapHash() const
A cheap hash function that just returns 64 bits from the result, it can be used when the contents are...
Definition: uint256.h:132
const std::string strMessageMagic
Definition: validation.cpp:251
bool fCheckpointsEnabled
Definition: validation.cpp:232
bool LoadGenesisBlock(const CChainParams &chainparams)
Ensures we have a genesis block in the block tree, possibly writing one to disk.
CBlockFileInfo * GetBlockFileInfo(size_t n)
Get block file info entry for one block file.
VersionBitsCache versionbitscache
ScriptError GetScriptError() const
Definition: validation.h:384
bool DumpMempool()
Dump the mempool to disk.
uint64_t nLastBlockTx
Definition: miner.cpp:41
std::unique_ptr< CBlockTreeDB > pblocktree
Global variable that points to the active block tree (protected by cs_main)
Definition: validation.cpp:299
void UnloadBlockIndex()
Unload database information.
unsigned int nTx
Number of transactions in this block.
Definition: chain.h:199
Nodes collect new transactions into a block, hash them into a hash tree, and scan through nonce value...
Definition: block.h:20
void UnlinkPrunedFiles(const std::set< int > &setFilesToPrune)
Actually unlink the specified files.
std::unique_ptr< CCoinsViewCache > pcoinsTip
Global variable that points to the active CCoinsView (protected by cs_main)
Definition: validation.cpp:298
bool fCheckBlockIndex
Definition: validation.cpp:231
Mutex g_best_block_mutex
Definition: validation.cpp:221
PrecomputedTransactionData * txdata
Definition: validation.h:365
CBlockIndex * LookupBlockIndex(const uint256 &hash)
Definition: validation.h:431