Changeset View
Changeset View
Standalone View
Standalone View
src/validation.h
Show All 11 Lines | |||||
#endif | #endif | ||||
#include <amount.h> | #include <amount.h> | ||||
#include <attributes.h> | #include <attributes.h> | ||||
#include <blockfileinfo.h> | #include <blockfileinfo.h> | ||||
#include <blockindexworkcomparator.h> | #include <blockindexworkcomparator.h> | ||||
#include <coins.h> | #include <coins.h> | ||||
#include <consensus/consensus.h> | #include <consensus/consensus.h> | ||||
#include <consensus/validation.h> | |||||
#include <disconnectresult.h> | #include <disconnectresult.h> | ||||
#include <flatfile.h> | #include <flatfile.h> | ||||
#include <fs.h> | #include <fs.h> | ||||
#include <node/utxo_snapshot.h> | #include <node/utxo_snapshot.h> | ||||
#include <protocol.h> // For CMessageHeader::MessageMagic | #include <protocol.h> // For CMessageHeader::MessageMagic | ||||
#include <script/script_error.h> | #include <script/script_error.h> | ||||
#include <script/script_metrics.h> | #include <script/script_metrics.h> | ||||
#include <sync.h> | #include <sync.h> | ||||
#include <txdb.h> | #include <txdb.h> | ||||
#include <txmempool.h> // For CTxMemPool::cs | #include <txmempool.h> // For CTxMemPool::cs | ||||
#include <util/check.h> | |||||
#include <versionbits.h> | #include <versionbits.h> | ||||
#include <atomic> | #include <atomic> | ||||
#include <cstdint> | #include <cstdint> | ||||
#include <map> | #include <map> | ||||
#include <memory> | #include <memory> | ||||
#include <optional> | #include <optional> | ||||
#include <set> | #include <set> | ||||
Show All 12 Lines | |||||
class CConnman; | class CConnman; | ||||
class CInv; | class CInv; | ||||
class ChainstateManager; | class ChainstateManager; | ||||
class Config; | class Config; | ||||
class CScriptCheck; | class CScriptCheck; | ||||
class CTxMemPool; | class CTxMemPool; | ||||
class CTxUndo; | class CTxUndo; | ||||
class DisconnectedBlockTransactions; | class DisconnectedBlockTransactions; | ||||
class TxValidationState; | |||||
struct CCheckpointData; | struct CCheckpointData; | ||||
struct ChainTxData; | struct ChainTxData; | ||||
struct FlatFilePos; | struct FlatFilePos; | ||||
struct PrecomputedTransactionData; | struct PrecomputedTransactionData; | ||||
struct LockPoints; | struct LockPoints; | ||||
struct AssumeutxoData; | struct AssumeutxoData; | ||||
▲ Show 20 Lines • Show All 203 Lines • ▼ Show 20 Lines | |||||
*/ | */ | ||||
void UnlinkPrunedFiles(const std::set<int> &setFilesToPrune); | void UnlinkPrunedFiles(const std::set<int> &setFilesToPrune); | ||||
/** Prune block files up to a given height */ | /** Prune block files up to a given height */ | ||||
void PruneBlockFilesManual(CChainState &active_chainstate, | void PruneBlockFilesManual(CChainState &active_chainstate, | ||||
int nManualPruneHeight); | int nManualPruneHeight); | ||||
/** | /** | ||||
* (try to) add transaction to memory pool | * Validation result for a single transaction mempool acceptance. | ||||
* @param[out] fee_out optional argument to return tx fee to the caller | */ | ||||
struct MempoolAcceptResult { | |||||
/** | |||||
* Used to indicate the results of mempool validation, | |||||
* including the possibility of unfinished validation. | |||||
*/ | */ | ||||
bool AcceptToMemoryPool(CChainState &active_chainstate, const Config &config, | enum class ResultType { | ||||
CTxMemPool &pool, TxValidationState &state, | //! Fully validated, valid. | ||||
const CTransactionRef &tx, bool bypass_limits, | VALID, | ||||
bool test_accept = false, Amount *fee_out = nullptr) | //! Invalid. | ||||
INVALID, | |||||
}; | |||||
ResultType m_result_type; | |||||
TxValidationState m_state; | |||||
// The following fields are only present when m_result_type = | |||||
// ResultType::VALID | |||||
/** Raw base fees. */ | |||||
std::optional<Amount> m_base_fees; | |||||
/** Constructor for failure case */ | |||||
explicit MempoolAcceptResult(TxValidationState state) | |||||
: m_result_type(ResultType::INVALID), m_state(state), | |||||
m_base_fees(std::nullopt) { | |||||
// Can be invalid or error | |||||
Assume(!state.IsValid()); | |||||
} | |||||
/** Constructor for success case */ | |||||
explicit MempoolAcceptResult(Amount fees) | |||||
: m_result_type(ResultType::VALID), m_state(TxValidationState{}), | |||||
m_base_fees(fees) {} | |||||
}; | |||||
/** | |||||
* (try to) add transaction to memory pool | |||||
* | |||||
* @param[in] bypass_limits When true, don't enforce mempool fee limits. | |||||
* @param[in] test_accept When true, run validation checks but don't submit | |||||
* to mempool. | |||||
*/ | |||||
MempoolAcceptResult | |||||
AcceptToMemoryPool(CChainState &active_chainstate, const Config &config, | |||||
CTxMemPool &pool, const CTransactionRef &tx, | |||||
bool bypass_limits, bool test_accept = false) | |||||
EXCLUSIVE_LOCKS_REQUIRED(cs_main); | EXCLUSIVE_LOCKS_REQUIRED(cs_main); | ||||
/** | /** | ||||
* Simple class for regulating resource usage during CheckInputScripts (and | * Simple class for regulating resource usage during CheckInputScripts (and | ||||
* CScriptCheck), atomic so as to be compatible with parallel validation. | * CScriptCheck), atomic so as to be compatible with parallel validation. | ||||
*/ | */ | ||||
class CheckInputsLimiter { | class CheckInputsLimiter { | ||||
protected: | protected: | ||||
▲ Show 20 Lines • Show All 1,036 Lines • Show Last 20 Lines |