Changeset View
Changeset View
Standalone View
Standalone View
src/validation.h
Show All 30 Lines | |||||
#include <exception> | #include <exception> | ||||
#include <map> | #include <map> | ||||
#include <memory> | #include <memory> | ||||
#include <set> | #include <set> | ||||
#include <string> | #include <string> | ||||
#include <utility> | #include <utility> | ||||
#include <vector> | #include <vector> | ||||
class arith_uint256; | |||||
class CBlockIndex; | class CBlockIndex; | ||||
class CBlockTreeDB; | class CBlockTreeDB; | ||||
class CChainParams; | class CChainParams; | ||||
class CChain; | class CChain; | ||||
class CCoinsViewDB; | class CCoinsViewDB; | ||||
class CConnman; | class CConnman; | ||||
class CInv; | class CInv; | ||||
class Config; | class Config; | ||||
▲ Show 20 Lines • Show All 371 Lines • ▼ Show 20 Lines | |||||
*/ | */ | ||||
void PruneOneBlockFile(const int fileNumber) EXCLUSIVE_LOCKS_REQUIRED(cs_main); | void PruneOneBlockFile(const int fileNumber) EXCLUSIVE_LOCKS_REQUIRED(cs_main); | ||||
/** | /** | ||||
* Actually unlink the specified files | * Actually unlink the specified files | ||||
*/ | */ | ||||
void UnlinkPrunedFiles(const std::set<int> &setFilesToPrune); | void UnlinkPrunedFiles(const std::set<int> &setFilesToPrune); | ||||
/** Flush all state, indexes and buffers to disk. */ | |||||
void FlushStateToDisk(); | |||||
/** Prune block files and flush state to disk. */ | |||||
void PruneAndFlush(); | |||||
/** Prune block files up to a given height */ | /** Prune block files up to a given height */ | ||||
void PruneBlockFilesManual(int nManualPruneHeight); | void PruneBlockFilesManual(int nManualPruneHeight); | ||||
/** | /** | ||||
* (try to) add transaction to memory pool | * (try to) add transaction to memory pool | ||||
*/ | */ | ||||
bool AcceptToMemoryPool(const Config &config, CTxMemPool &pool, | bool AcceptToMemoryPool(const Config &config, CTxMemPool &pool, | ||||
CValidationState &state, const CTransactionRef &tx, | CValidationState &state, const CTransactionRef &tx, | ||||
▲ Show 20 Lines • Show All 262 Lines • ▼ Show 20 Lines | |||||
/** Replay blocks that aren't fully applied to the database. */ | /** Replay blocks that aren't fully applied to the database. */ | ||||
bool ReplayBlocks(const Consensus::Params ¶ms, 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) | ||||
EXCLUSIVE_LOCKS_REQUIRED(cs_main); | EXCLUSIVE_LOCKS_REQUIRED(cs_main); | ||||
/** @see CChainState::FlushStateToDisk */ | |||||
enum class FlushStateMode { NONE, IF_NEEDED, PERIODIC, ALWAYS }; | |||||
/** | /** | ||||
* CChainState stores and provides an API to update our local knowledge of the | * CChainState stores and provides an API to update our local knowledge of the | ||||
* current best chain and header tree. | * current best chain and header tree. | ||||
* | * | ||||
* It generally provides access to the current block tree, as well as functions | * It generally provides access to the current block tree, as well as functions | ||||
* to provide new data, which it will appropriately validate and incorporate in | * to provide new data, which it will appropriately validate and incorporate in | ||||
* its state as necessary. | * its state as necessary. | ||||
* | * | ||||
▲ Show 20 Lines • Show All 58 Lines • ▼ Show 20 Lines | public: | ||||
std::multimap<CBlockIndex *, CBlockIndex *> mapBlocksUnlinked; | std::multimap<CBlockIndex *, CBlockIndex *> mapBlocksUnlinked; | ||||
CBlockIndex *pindexBestInvalid = nullptr; | CBlockIndex *pindexBestInvalid = nullptr; | ||||
CBlockIndex *pindexBestParked = nullptr; | CBlockIndex *pindexBestParked = nullptr; | ||||
CBlockIndex const *pindexFinalized = nullptr; | CBlockIndex const *pindexFinalized = nullptr; | ||||
bool LoadBlockIndex(const Config &config, CBlockTreeDB &blocktree) | bool LoadBlockIndex(const Config &config, CBlockTreeDB &blocktree) | ||||
EXCLUSIVE_LOCKS_REQUIRED(cs_main); | EXCLUSIVE_LOCKS_REQUIRED(cs_main); | ||||
/** | |||||
* Update the on-disk chain state. | |||||
* The caches and indexes are flushed depending on the mode we're called | |||||
* with if they're too large, if it's been a while since the last write, or | |||||
* always and in all cases if we're in prune mode and are deleting files. | |||||
* | |||||
* If FlushStateMode::NONE is used, then FlushStateToDisk(...) won't do | |||||
* anything besides checking if we need to prune. | |||||
*/ | |||||
bool FlushStateToDisk(const CChainParams &chainparams, | |||||
CValidationState &state, FlushStateMode mode, | |||||
int nManualPruneHeight = 0); | |||||
//! Unconditionally flush all changes to disk. | |||||
void ForceFlushStateToDisk(); | |||||
//! Prune blockfiles from the disk if necessary and then flush chainstate | |||||
//! changes if we pruned. | |||||
void PruneAndFlush(); | |||||
bool ActivateBestChain( | bool ActivateBestChain( | ||||
const Config &config, CValidationState &state, | const Config &config, CValidationState &state, | ||||
std::shared_ptr<const CBlock> pblock = std::shared_ptr<const CBlock>()); | std::shared_ptr<const CBlock> pblock = std::shared_ptr<const CBlock>()); | ||||
/** | /** | ||||
* If a block header hasn't already been seen, call CheckBlockHeader on it, | * If a block header hasn't already been seen, call CheckBlockHeader on it, | ||||
* ensure that it doesn't descend from an invalid block, and then add it to | * ensure that it doesn't descend from an invalid block, and then add it to | ||||
* mapBlockIndex. | * mapBlockIndex. | ||||
▲ Show 20 Lines • Show All 193 Lines • Show Last 20 Lines |