Changeset View
Changeset View
Standalone View
Standalone View
src/validation.h
Show All 9 Lines | |||||
#if defined(HAVE_CONFIG_H) | #if defined(HAVE_CONFIG_H) | ||||
#include <config/bitcoin-config.h> | #include <config/bitcoin-config.h> | ||||
#endif | #endif | ||||
#include <amount.h> | #include <amount.h> | ||||
#include <blockfileinfo.h> | #include <blockfileinfo.h> | ||||
#include <coins.h> | #include <coins.h> | ||||
#include <consensus/consensus.h> | #include <consensus/consensus.h> | ||||
#include <consensus/params.h> | |||||
#include <flatfile.h> | #include <flatfile.h> | ||||
#include <fs.h> | #include <fs.h> | ||||
#include <protocol.h> // For CMessageHeader::MessageMagic | #include <protocol.h> // For CMessageHeader::MessageMagic | ||||
#include <script/script_error.h> | #include <script/script_error.h> | ||||
#include <sync.h> | #include <sync.h> | ||||
#include <versionbits.h> | #include <versionbits.h> | ||||
#include <algorithm> | #include <algorithm> | ||||
Show All 21 Lines | |||||
class CTxUndo; | class CTxUndo; | ||||
class CValidationState; | class CValidationState; | ||||
struct FlatFilePos; | struct FlatFilePos; | ||||
struct ChainTxData; | struct ChainTxData; | ||||
struct PrecomputedTransactionData; | struct PrecomputedTransactionData; | ||||
struct LockPoints; | struct LockPoints; | ||||
namespace Consensus { | |||||
struct Params; | |||||
} | |||||
#define MIN_TRANSACTION_SIZE \ | #define MIN_TRANSACTION_SIZE \ | ||||
(::GetSerializeSize(CTransaction(), SER_NETWORK, PROTOCOL_VERSION)) | (::GetSerializeSize(CTransaction(), SER_NETWORK, PROTOCOL_VERSION)) | ||||
/** Default for -whitelistrelay. */ | /** Default for -whitelistrelay. */ | ||||
static const bool DEFAULT_WHITELISTRELAY = true; | static const bool DEFAULT_WHITELISTRELAY = true; | ||||
/** Default for -whitelistforcerelay. */ | /** Default for -whitelistforcerelay. */ | ||||
static const bool DEFAULT_WHITELISTFORCERELAY = true; | static const bool DEFAULT_WHITELISTFORCERELAY = true; | ||||
/** Default for -minrelaytxfee, minimum relay fee for transactions */ | /** Default for -minrelaytxfee, minimum relay fee for transactions */ | ||||
▲ Show 20 Lines • Show All 330 Lines • ▼ Show 20 Lines | |||||
* Check whether we are doing an initial block download (synchronizing from disk | * Check whether we are doing an initial block download (synchronizing from disk | ||||
* or network) | * or network) | ||||
*/ | */ | ||||
bool IsInitialBlockDownload(); | bool IsInitialBlockDownload(); | ||||
/** | /** | ||||
* Retrieve a transaction (from memory pool, or from disk, if possible). | * Retrieve a transaction (from memory pool, or from disk, if possible). | ||||
*/ | */ | ||||
bool GetTransaction(const Config &config, const TxId &txid, CTransactionRef &tx, | bool GetTransaction(const Consensus::Params ¶ms, const TxId &txid, | ||||
uint256 &hashBlock, bool fAllowSlow = false, | CTransactionRef &tx, uint256 &hashBlock, | ||||
CBlockIndex *blockIndex = nullptr); | bool fAllowSlow = false, CBlockIndex *blockIndex = nullptr); | ||||
/** | /** | ||||
* Find the best known block, and make it the active tip of the block chain. | * Find the best known block, and make it the active tip of the block chain. | ||||
* If it fails, the tip is not updated. | * If it fails, the tip is not updated. | ||||
* | * | ||||
* pblock is either nullptr or a pointer to a block that is already loaded | * pblock is either nullptr or a pointer to a block that is already loaded | ||||
* in memory (to avoid loading it from disk again). | * in memory (to avoid loading it from disk again). | ||||
* | * | ||||
▲ Show 20 Lines • Show All 140 Lines • ▼ Show 20 Lines | void swap(CScriptCheck &check) { | ||||
std::swap(txdata, check.txdata); | std::swap(txdata, check.txdata); | ||||
} | } | ||||
ScriptError GetScriptError() const { return error; } | ScriptError GetScriptError() const { return error; } | ||||
}; | }; | ||||
/** Functions for disk access for blocks */ | /** Functions for disk access for blocks */ | ||||
bool ReadBlockFromDisk(CBlock &block, const FlatFilePos &pos, | bool ReadBlockFromDisk(CBlock &block, const FlatFilePos &pos, | ||||
const Config &config); | const Consensus::Params ¶ms); | ||||
bool ReadBlockFromDisk(CBlock &block, const CBlockIndex *pindex, | bool ReadBlockFromDisk(CBlock &block, const CBlockIndex *pindex, | ||||
const Config &config); | const Consensus::Params ¶ms); | ||||
/** Functions for validating blocks and updating the block tree */ | /** Functions for validating blocks and updating the block tree */ | ||||
/** | /** | ||||
* Context-independent validity checks. | * Context-independent validity checks. | ||||
* | * | ||||
* Returns true if the provided block is valid (has valid header, | * Returns true if the provided block is valid (has valid header, | ||||
* transactions are valid, block is a valid size, etc.) | * transactions are valid, block is a valid size, etc.) | ||||
Show All 36 Lines | |||||
public: | public: | ||||
CVerifyDB(); | CVerifyDB(); | ||||
~CVerifyDB(); | ~CVerifyDB(); | ||||
bool VerifyDB(const Config &config, CCoinsView *coinsview, int nCheckLevel, | bool VerifyDB(const Config &config, CCoinsView *coinsview, int nCheckLevel, | ||||
int nCheckDepth); | int nCheckDepth); | ||||
}; | }; | ||||
/** Replay blocks that aren't fully applied to the database. */ | /** Replay blocks that aren't fully applied to the database. */ | ||||
bool ReplayBlocks(const Config &config, CCoinsView *view); | bool ReplayBlocks(const Consensus::Params ¶ms, CCoinsView *view); | ||||
/** Find the last common block between the parameter chain and a locator. */ | /** Find the last common block between the parameter chain and a locator. */ | ||||
CBlockIndex *FindForkInGlobalIndex(const CChain &chain, | CBlockIndex *FindForkInGlobalIndex(const CChain &chain, | ||||
const CBlockLocator &locator); | const CBlockLocator &locator); | ||||
/** | /** | ||||
* Treats a block as if it were received before others with the same work, | * Treats a block as if it were received before others with the same work, | ||||
* making it the active chain tip if applicable. Successive calls to | * making it the active chain tip if applicable. Successive calls to | ||||
▲ Show 20 Lines • Show All 95 Lines • Show Last 20 Lines |