PIVX Core  5.6.99
P2P Digital Currency
validation.h
Go to the documentation of this file.
1 // Copyright (c) 2009-2010 Satoshi Nakamoto
2 // Copyright (c) 2009-2014 The Bitcoin developers
3 // Copyright (c) 2014-2015 The Dash developers
4 // Copyright (c) 2011-2013 The PPCoin developers
5 // Copyright (c) 2013-2014 The NovaCoin Developers
6 // Copyright (c) 2014-2018 The BlackCoin Developers
7 // Copyright (c) 2015-2022 The PIVX Core developers
8 // Distributed under the MIT software license, see the accompanying
9 // file COPYING or http://www.opensource.org/licenses/mit-license.php.
10 
11 #ifndef PIVX_VALIDATION_H
12 #define PIVX_VALIDATION_H
13 
14 #if defined(HAVE_CONFIG_H)
15 #include "config/pivx-config.h"
16 #endif
17 
18 #include "amount.h"
19 #include "chain.h"
20 #include "coins.h"
21 #include "consensus/validation.h"
22 #include "fs.h"
23 #include "moneysupply.h"
24 #include "policy/feerate.h"
25 #include "script/script_error.h"
26 #include "sync.h"
27 #include "txmempool.h"
28 
29 #include <algorithm>
30 #include <atomic>
31 #include <exception>
32 #include <map>
33 #include <memory>
34 #include <set>
35 #include <stdint.h>
36 #include <string>
37 #include <utility>
38 #include <vector>
39 
40 class AccumulatorCache;
41 class CBlockIndex;
42 class CBlockTreeDB;
43 class CBudgetManager;
44 class CCoinsViewDB;
45 class CZerocoinDB;
46 class CSporkDB;
47 class CBloomFilter;
48 class CInv;
49 class CConnman;
50 class CNode;
51 class CScriptCheck;
52 
54 
56 static const unsigned int DEFAULT_ANCESTOR_LIMIT = 25;
58 static const unsigned int DEFAULT_ANCESTOR_SIZE_LIMIT = 101;
60 static const int DEFAULT_BANSCORE_THRESHOLD = 100;
62 static const bool DEFAULT_PERSIST_MEMPOOL = true;
64 static const unsigned int DEFAULT_DESCENDANT_LIMIT = 25;
66 static const unsigned int DEFAULT_DESCENDANT_SIZE_LIMIT = 101;
68 static const unsigned int DEFAULT_MEMPOOL_EXPIRY = 72;
70 static const bool DEFAULT_TXINDEX = true;
71 static const bool DEFAULT_CHECKPOINTS_ENABLED = true;
73 static const unsigned int MAX_STANDARD_TX_SIZE = 100000;
74 static const unsigned int MAX_ZEROCOIN_TX_SIZE = 150000;
76 static const unsigned int MAX_DISCONNECTED_TX_POOL_SIZE = 20000;
78 static const signed int DEFAULT_CHECKBLOCKS = 6;
79 static const unsigned int DEFAULT_CHECKLEVEL = 3;
81 static const unsigned int MAX_BLOCKFILE_SIZE = 0x8000000; // 128 MiB
83 static const unsigned int BLOCKFILE_CHUNK_SIZE = 0x1000000; // 16 MiB
85 static const unsigned int UNDOFILE_CHUNK_SIZE = 0x100000; // 1 MiB
87 static const int MAX_SCRIPTCHECK_THREADS = 16;
89 static const int DEFAULT_SCRIPTCHECK_THREADS = 0;
91 static const int MAX_BLOCKS_IN_TRANSIT_PER_PEER = 16;
93 static const unsigned int BLOCK_STALLING_TIMEOUT = 2;
96 static const unsigned int MAX_HEADERS_RESULTS = 2000;
101 static const unsigned int BLOCK_DOWNLOAD_WINDOW = 1024;
103 static const unsigned int DATABASE_WRITE_INTERVAL = 60 * 60;
105 static const unsigned int DATABASE_FLUSH_INTERVAL = 24 * 60 * 60;
107 static constexpr std::chrono::hours AVG_LOCAL_ADDRESS_BROADCAST_INTERVAL{24};
109 static constexpr std::chrono::seconds AVG_ADDRESS_BROADCAST_INTERVAL{30};
111 static const unsigned int DEFAULT_SHIELDEDTXFEE_K = 100;
113  static const bool DEFAULT_PEERBLOOMFILTERS = true;
115 static const int64_t DEFAULT_MAX_TIP_AGE = 24 * 60 * 60;
117 static const int64_t MAX_FEE_ESTIMATION_TIP_AGE = 3 * 60 * 60;
118 
119 struct BlockHasher {
120  size_t operator()(const uint256& hash) const { return hash.GetCheapHash(); }
121 };
122 
123 extern CScript COINBASE_FLAGS;
124 extern RecursiveMutex cs_main;
125 extern CTxMemPool mempool;
126 typedef std::unordered_map<uint256, CBlockIndex*, BlockHasher> BlockMap;
127 typedef std::unordered_multimap<uint256, CBlockIndex*, BlockHasher> PrevBlockMap;
128 extern BlockMap mapBlockIndex;
130 extern uint64_t nLastBlockTx;
131 extern uint64_t nLastBlockSize;
132 
133 // Best block section
135 extern std::condition_variable g_best_block_cv;
136 extern uint256 g_best_block;
137 extern int64_t g_best_block_time;
138 
139 extern std::atomic<bool> fImporting;
140 extern std::atomic<bool> fReindex;
141 extern int nScriptCheckThreads;
142 extern bool fTxIndex;
143 extern bool fRequireStandard;
144 extern bool fCheckBlockIndex;
145 extern size_t nCoinCacheUsage;
146 extern CFeeRate minRelayTxFee;
147 extern int64_t nMaxTipAge;
148 
149 extern bool fLargeWorkForkFound;
150 extern bool fLargeWorkInvalidChainFound;
151 
152 extern std::map<uint256, int64_t> mapRejectedBlocks;
153 
155 
158 
175 bool ProcessNewBlock(const std::shared_ptr<const CBlock>& pblock, const FlatFilePos* dbp);
176 
178 FILE* OpenBlockFile(const FlatFilePos& pos, bool fReadOnly = false);
180 FILE* OpenUndoFile(const FlatFilePos& pos, bool fReadOnly = false);
182 fs::path GetBlockPosFilename(const FlatFilePos &pos);
184 bool LoadExternalBlockFile(FILE* fileIn, FlatFilePos* dbp = nullptr);
186 bool LoadGenesisBlock();
189 bool LoadBlockIndex(std::string& strError) EXCLUSIVE_LOCKS_REQUIRED(cs_main);
193 void UnloadBlockIndex();
195 int ActiveProtocol();
197 void ThreadScriptCheck();
198 
202 bool GetTransaction(const uint256& hash, CTransactionRef& tx, uint256& hashBlock, bool fAllowSlow = false, CBlockIndex* blockIndex = nullptr);
204 bool GetOutput(const uint256& hash, unsigned int index, CValidationState& state, CTxOut& out);
205 
206 double ConvertBitsToDouble(unsigned int nBits);
207 int64_t GetMasternodePayment(int nHeight);
208 
210 bool ActivateBestChain(CValidationState& state, std::shared_ptr<const CBlock> pblock = std::shared_ptr<const CBlock>());
211 CAmount GetBlockValue(int nHeight);
212 
216 void FlushStateToDisk();
217 
218 
220 bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState& state, const CTransactionRef& tx, bool fLimitFree,
221  bool* pfMissingInputs, bool fOverrideMempoolLimit = false,
222  bool fRejectInsaneFee = false, bool ignoreFees = false) EXCLUSIVE_LOCKS_REQUIRED(cs_main);
223 
225 bool AcceptToMemoryPoolWithTime(CTxMemPool& pool, CValidationState &state, const CTransactionRef &tx, bool fLimitFree,
226  bool* pfMissingInputs, int64_t nAcceptTime, bool fOverrideMempoolLimit = false,
227  bool fRejectInsaneFee = false, bool ignoreFees = false) EXCLUSIVE_LOCKS_REQUIRED(cs_main);
228 
229 CAmount GetMinRelayFee(const CTransaction& tx, const CTxMemPool& pool, unsigned int nBytes);
230 CAmount GetMinRelayFee(unsigned int nBytes);
235 
253 bool CheckInputs(const CTransaction& tx, CValidationState& state, const CCoinsViewCache& view, bool fScriptChecks, unsigned int flags, bool cacheStore, PrecomputedTransactionData& precomTxData, std::vector<CScriptCheck>* pvChecks = nullptr);
254 
256 void UpdateCoins(const CTransaction& tx, CCoinsViewCache& inputs, int nHeight, bool fSkipInvalid = false);
257 
265 bool CheckFinalTx(const CTransactionRef& tx, int flags = -1);
266 
267 
273 {
274 private:
277  unsigned int nIn;
278  unsigned int nFlags;
282 
283 public:
284  CScriptCheck() : ptxTo(0), nIn(0), nFlags(0), cacheStore(false), error(SCRIPT_ERR_UNKNOWN_ERROR), precomTxData(nullptr) {}
285  CScriptCheck(const CTxOut& outIn, const CTransaction& txToIn, unsigned int nInIn, unsigned int nFlagsIn, bool cacheIn, PrecomputedTransactionData* cachedHashesIn) :
286  m_tx_out(outIn),
287  ptxTo(&txToIn),
288  nIn(nInIn),
289  nFlags(nFlagsIn),
290  cacheStore(cacheIn),
292  precomTxData(cachedHashesIn) {}
293 
294  bool operator()();
295 
296  void swap(CScriptCheck& check)
297  {
298  std::swap(ptxTo, check.ptxTo);
299  std::swap(m_tx_out, check.m_tx_out);
300  std::swap(nIn, check.nIn);
301  std::swap(nFlags, check.nFlags);
302  std::swap(cacheStore, check.cacheStore);
303  std::swap(error, check.error);
304  std::swap(precomTxData, check.precomTxData);
305  }
306 
307  ScriptError GetScriptError() const { return error; }
308 };
309 
310 
312 bool WriteBlockToDisk(const CBlock& block, FlatFilePos& pos);
313 bool ReadBlockFromDisk(CBlock& block, const FlatFilePos& pos);
314 bool ReadBlockFromDisk(CBlock& block, const CBlockIndex* pindex);
315 
316 
320 bool CheckBlock(const CBlock& block, CValidationState& state, bool fCheckPOW = true, bool fCheckMerkleRoot = true, bool fCheckSig = true) EXCLUSIVE_LOCKS_REQUIRED(cs_main);
321 bool CheckWork(const CBlock& block, const CBlockIndex* const pindexPrev);
322 
325 bool ContextualCheckBlock(const CBlock& block, CValidationState& state, CBlockIndex* pindexPrev);
326 
328 bool TestBlockValidity(CValidationState& state, const CBlock& block, CBlockIndex* pindexPrev, bool fCheckPOW = true, bool fCheckMerkleRoot = true, bool fCheckBlockSig = true) EXCLUSIVE_LOCKS_REQUIRED(cs_main);
329 
330 bool AcceptBlockHeader(const CBlock& block, CValidationState& state, CBlockIndex** ppindex = nullptr, CBlockIndex* pindexPrev = nullptr) EXCLUSIVE_LOCKS_REQUIRED(cs_main);
331 
332 
335 {
336 public:
337  CVerifyDB();
338  ~CVerifyDB();
339  bool VerifyDB(CCoinsView* coinsview, int nCheckLevel, int nCheckDepth);
340 };
341 
343 bool ReplayBlocks(const CChainParams& params, CCoinsView* view);
344 
346 {
348  BlockMap::const_iterator it = mapBlockIndex.find(hash);
349  return it == mapBlockIndex.end() ? nullptr : it->second;
350 }
351 
354 
357 
359 bool ReconsiderBlock(CValidationState& state, CBlockIndex* pindex);
360 
362 extern CChain chainActive;
363 
365 extern std::unique_ptr<CCoinsViewDB> pcoinsdbview;
366 
368 extern std::unique_ptr<CCoinsViewCache> pcoinsTip;
369 
371 extern std::unique_ptr<CBlockTreeDB> pblocktree;
372 
374 extern std::unique_ptr<CZerocoinDB> zerocoinDB;
375 
377 extern std::unique_ptr<AccumulatorCache> accumulatorCache;
378 
380 extern std::unique_ptr<CSporkDB> pSporkDB;
381 
386 
392 int GetSpendHeight(const CCoinsViewCache& inputs);
393 
398 static const unsigned int REJECT_INTERNAL = 0x100;
400 static const unsigned int REJECT_HIGHFEE = 0x100;
402 static const unsigned int REJECT_ALREADY_KNOWN = 0x101;
404 static const unsigned int REJECT_CONFLICT = 0x102;
405 
408 
410 bool DumpMempool(const CTxMemPool& pool);
411 
413 bool LoadMempool(CTxMemPool& pool);
414 
415 #endif // PIVX_VALIDATION_H
int64_t CAmount
Amount in PIV (Can be negative)
Definition: amount.h:13
true
Definition: bls_dkg.cpp:153
false
Definition: bls_dkg.cpp:151
Nodes collect new transactions into a block, hash them into a hash tree, and scan through nonce value...
Definition: block.h:23
Definition: block.h:80
The block chain is a tree shaped structure starting with the genesis block at the root,...
Definition: chain.h:139
Access to the block database (blocks/index/)
Definition: txdb.h:128
BloomFilter is a probabilistic filter which SPV clients provide so that we can filter the transaction...
Definition: bloom.h:45
An in-memory indexed chain of blocks.
Definition: chain.h:393
CChainParams defines various tweakable parameters of a given instance of the PIVX system.
Definition: chainparams.h:43
CCoinsView that adds a memory cache for transactions to another CCoinsView.
Definition: coins.h:283
CCoinsView backed by the LevelDB coin database (chainstate/)
Definition: txdb.h:71
Abstract view on the open txout dataset.
Definition: coins.h:201
Definition: net.h:145
Fee rate in PIV per kilobyte: CAmount / kB.
Definition: feerate.h:20
inv message data
Definition: protocol.h:466
Information about a peer.
Definition: net.h:669
Closure representing one script verification Note that this stores references to the spending transac...
Definition: validation.h:273
ScriptError GetScriptError() const
Definition: validation.h:307
void swap(CScriptCheck &check)
Definition: validation.h:296
CTxOut m_tx_out
Definition: validation.h:275
PrecomputedTransactionData * precomTxData
Definition: validation.h:281
bool cacheStore
Definition: validation.h:279
ScriptError error
Definition: validation.h:280
unsigned int nFlags
Definition: validation.h:278
CScriptCheck(const CTxOut &outIn, const CTransaction &txToIn, unsigned int nInIn, unsigned int nFlagsIn, bool cacheIn, PrecomputedTransactionData *cachedHashesIn)
Definition: validation.h:285
const CTransaction * ptxTo
Definition: validation.h:276
unsigned int nIn
Definition: validation.h:277
Serialized script, used inside transaction inputs and outputs.
Definition: script.h:381
The basic transaction that is broadcasted on the network and contained in blocks.
Definition: transaction.h:244
CTxMemPool stores valid-according-to-the-current-best-chain transactions that may be included in the ...
Definition: txmempool.h:384
An output of a transaction.
Definition: transaction.h:137
Capture information about block/transaction validation.
Definition: validation.h:24
RAII wrapper for VerifyDB: Verify consistency of the block and coin databases.
Definition: validation.h:335
Zerocoin database (zerocoin/)
Definition: txdb.h:152
256-bit opaque blob.
Definition: uint256.h:138
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:149
Definition: uint256.h:212
int flags
Definition: pivx-tx.cpp:400
enum ScriptError_t ScriptError
@ SCRIPT_ERR_UNKNOWN_ERROR
Definition: script_error.h:13
size_t operator()(const uint256 &hash) const
Definition: validation.h:120
Describes a place in the block chain to another node such that if the other node doesn't have the sam...
Definition: block.h:154
#define AssertLockHeld(cs)
Definition: sync.h:75
bool error(const char *fmt, const Args &... args)
Definition: system.h:77
#define EXCLUSIVE_LOCKS_REQUIRED(...)
Definition: threadsafety.h:50
std::shared_ptr< const CTransaction > CTransactionRef
Definition: transaction.h:456
bool AcceptToMemoryPoolWithTime(CTxMemPool &pool, CValidationState &state, const CTransactionRef &tx, bool fLimitFree, bool *pfMissingInputs, int64_t nAcceptTime, bool fOverrideMempoolLimit=false, bool fRejectInsaneFee=false, bool ignoreFees=false) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
(try to) add transaction to memory pool with a specified acceptance time
Definition: validation.cpp:632
double ConvertBitsToDouble(unsigned int nBits)
Definition: validation.cpp:797
bool TestBlockValidity(CValidationState &state, const CBlock &block, CBlockIndex *pindexPrev, bool fCheckPOW=true, bool fCheckMerkleRoot=true, bool fCheckBlockSig=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,...
void FlushStateToDisk()
Flush all state, indexes and buffers to disk.
bool LoadGenesisBlock()
Ensures we have a genesis block in the block tree, possibly writing one to disk.
FILE * OpenUndoFile(const FlatFilePos &pos, bool fReadOnly=false)
Open an undo file (rev?????.dat)
int ActiveProtocol()
See whether the protocol update is enforced for connected nodes.
std::unique_ptr< CBlockTreeDB > pblocktree
Global variable that points to the active block tree (protected by cs_main)
Definition: validation.cpp:207
bool fCheckBlockIndex
Definition: validation.cpp:98
std::unique_ptr< CZerocoinDB > zerocoinDB
Global variable that points to the zerocoin database (protected by cs_main)
Definition: validation.cpp:208
std::condition_variable g_best_block_cv
Definition: validation.cpp:89
int nScriptCheckThreads
Definition: validation.cpp:93
uint64_t nLastBlockTx
CAmount GetShieldedTxMinFee(const CTransaction &tx)
Return the minimum fee for a shielded tx.
Definition: validation.cpp:288
std::unique_ptr< CSporkDB > pSporkDB
Global variable that points to the spork database (protected by cs_main)
Definition: validation.cpp:209
bool LoadChainTip(const CChainParams &chainparams) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
Update the chain tip based on database information.
bool LoadBlockIndex(std::string &strError) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
Load the block tree and coins database from disk, initializing state if we're running with -reindex.
CMoneySupply MoneySupply
Definition: validation.cpp:114
CBlockIndex * LookupBlockIndex(const uint256 &hash) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
Definition: validation.h:345
bool DumpMempool(const CTxMemPool &pool)
Dump the mempool to disk.
bool WriteBlockToDisk(const CBlock &block, FlatFilePos &pos)
Functions for disk access for blocks.
Definition: validation.cpp:737
bool CheckBlock(const CBlock &block, CValidationState &state, bool fCheckPOW=true, bool fCheckMerkleRoot=true, bool fCheckSig=true) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
Functions for validating blocks and updating the block tree.
bool LoadMempool(CTxMemPool &pool)
Load the mempool from disk.
CFeeRate minRelayTxFee
Fees smaller than this (in upiv) are considered zero fee (for relaying, mining and transaction creati...
Definition: validation.cpp:108
bool CheckWork(const CBlock &block, const CBlockIndex *const pindexPrev)
CScript COINBASE_FLAGS
Constant stuff for coinbase transactions we create:
Definition: validation.cpp:119
bool IsInitialBlockDownload()
Check whether we are doing an initial block download (synchronizing from disk or network)
Definition: validation.cpp:862
bool ProcessNewBlock(const std::shared_ptr< const CBlock > &pblock, const FlatFilePos *dbp)
Process an incoming block.
bool fTxIndex
Definition: validation.cpp:96
std::unordered_map< uint256, CBlockIndex *, BlockHasher > BlockMap
Definition: validation.h:126
std::unique_ptr< CCoinsViewCache > pcoinsTip
Global variable that points to the active CCoinsView (protected by cs_main)
Definition: validation.cpp:206
int64_t g_best_block_time
Definition: validation.cpp:91
CBlockFileInfo * GetBlockFileInfo(size_t n)
Get block file info entry for one block file.
int64_t GetMasternodePayment(int nHeight)
Definition: validation.cpp:852
CAmount GetBlockValue(int nHeight)
Definition: validation.cpp:816
std::atomic< bool > fImporting
Definition: validation.cpp:94
FILE * OpenBlockFile(const FlatFilePos &pos, bool fReadOnly=false)
Open a block file (blk?????.dat)
bool ReconsiderBlock(CValidationState &state, CBlockIndex *pindex)
Remove invalidity status from a block and its descendants.
std::map< uint256, int64_t > mapRejectedBlocks
Definition: validation.cpp:112
bool AcceptBlockHeader(const CBlock &block, CValidationState &state, CBlockIndex **ppindex=nullptr, CBlockIndex *pindexPrev=nullptr) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
bool GetTransaction(const uint256 &hash, CTransactionRef &tx, uint256 &hashBlock, bool fAllowSlow=false, CBlockIndex *blockIndex=nullptr)
Retrieve a transaction (from memory pool, or from disk, if possible)
Definition: validation.cpp:671
BlockMap mapBlockIndex
Definition: validation.cpp:82
void ThreadScriptCheck()
Run an instance of the script checking thread.
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:181
Mutex g_best_block_mutex
Definition: validation.cpp:88
fs::path GetBlockPosFilename(const FlatFilePos &pos)
Translation to a filesystem path.
std::unordered_multimap< uint256, CBlockIndex *, BlockHasher > PrevBlockMap
Definition: validation.h:127
bool fLargeWorkInvalidChainFound
Definition: warnings.cpp:15
bool GetOutput(const uint256 &hash, unsigned int index, CValidationState &state, CTxOut &out)
Retrieve an output (from memory pool, or from disk, if possible)
Definition: validation.cpp:656
RecursiveMutex cs_main
Global state.
Definition: validation.cpp:80
bool ActivateBestChain(CValidationState &state, 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.
size_t nCoinCacheUsage
Definition: validation.cpp:99
CTxMemPool mempool
void UpdateCoins(const CTransaction &tx, CCoinsViewCache &inputs, int nHeight, bool fSkipInvalid=false)
Apply the effects of this transaction on the UTXO set represented by view.
bool InvalidateBlock(CValidationState &state, const CChainParams &chainparams, CBlockIndex *pindex) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
Mark a block as invalid.
std::unique_ptr< CCoinsViewDB > pcoinsdbview
Global variable that points to the coins database (protected by cs_main)
Definition: validation.cpp:205
void UnloadBlockIndex()
Unload database information.
bool ReadBlockFromDisk(CBlock &block, const FlatFilePos &pos)
Definition: validation.cpp:758
CAmount GetMinRelayFee(const CTransaction &tx, const CTxMemPool &pool, unsigned int nBytes)
Definition: validation.cpp:265
CBlockIndex * pindexBestHeader
Best header we've seen so far (used for getheaders queries' starting points).
Definition: validation.cpp:85
bool ReplayBlocks(const CChainParams &params, CCoinsView *view)
Replay blocks that aren't fully applied to the database.
PrevBlockMap mapPrevBlockIndex
Definition: validation.cpp:83
CBlockIndex * GetChainTip()
Return a reliable pointer (in mapBlockIndex) to the chain's tip index.
Definition: validation.cpp:194
bool CheckFinalTx(const CTransactionRef &tx, int flags=-1)
Check if transaction will be final in the next block to be created.
Definition: validation.cpp:224
std::atomic< bool > fReindex
Definition: validation.cpp:95
int GetSpendHeight(const CCoinsViewCache &inputs)
Return the spend height, which is one more than the inputs.GetBestBlock().
bool ContextualCheckBlockHeader(const CBlockHeader &block, CValidationState &state, CBlockIndex *pindexPrev) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
Context-dependent validity checks.
CChain chainActive
The currently-connected chain of blocks (protected by cs_main).
Definition: validation.cpp:84
bool AcceptToMemoryPool(CTxMemPool &pool, CValidationState &state, const CTransactionRef &tx, bool fLimitFree, bool *pfMissingInputs, bool fOverrideMempoolLimit=false, bool fRejectInsaneFee=false, bool ignoreFees=false) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
(try to) add transaction to memory pool
Definition: validation.cpp:649
bool fLargeWorkForkFound
Definition: warnings.cpp:14
bool ContextualCheckBlock(const CBlock &block, CValidationState &state, CBlockIndex *pindexPrev)
std::unique_ptr< AccumulatorCache > accumulatorCache
In-memory cache for the zerocoin accumulators.
Definition: validation.cpp:210
bool CheckInputs(const CTransaction &tx, CValidationState &state, const CCoinsViewCache &view, bool fScriptChecks, unsigned int flags, bool cacheStore, PrecomputedTransactionData &precomTxData, std::vector< CScriptCheck > *pvChecks=nullptr)
Check transaction inputs, and make sure any pay-to-script-hash transactions are evaluating IsStandard...
CBlockIndex * InsertBlockIndex(const uint256 &hash) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
Create a new block index entry for a given block hash.
uint256 g_best_block
Definition: validation.cpp:90
bool fRequireStandard
Definition: validation.cpp:97
int64_t nMaxTipAge
Definition: validation.cpp:102
uint64_t nLastBlockSize
bool LoadExternalBlockFile(FILE *fileIn, FlatFilePos *dbp=nullptr)
Import blocks from an external file.