From fa81c30c6f1adac79517c958090db174eb6aeda2 Mon Sep 17 00:00:00 2001 From: MarcoFalke Date: Sun, 18 Apr 2021 09:46:01 +0200 Subject: refactor: Move pruning/reindex/importing globals to blockstorage Can be reviewed with --color-moved=dimmed-zebra --- src/validation.h | 15 --------------- 1 file changed, 15 deletions(-) (limited to 'src/validation.h') diff --git a/src/validation.h b/src/validation.h index 9ae2838ead..bd5a0b46e5 100644 --- a/src/validation.h +++ b/src/validation.h @@ -112,8 +112,6 @@ typedef std::unordered_map BlockMap; extern Mutex g_best_block_mutex; extern std::condition_variable g_best_block_cv; extern uint256 g_best_block; -extern std::atomic_bool fImporting; -extern std::atomic_bool fReindex; /** Whether there are dedicated script-checking threads running. * False indicates all script checking is done on the main threadMessageHandler thread. */ @@ -135,13 +133,6 @@ extern arith_uint256 nMinimumChainWork; /** Best header we've seen so far (used for getheaders queries' starting points). */ extern CBlockIndex *pindexBestHeader; -/** Pruning-related variables and constants */ -/** True if any block files have ever been pruned. */ -extern bool fHavePruned; -/** True if we're running in -prune mode. */ -extern bool fPruneMode; -/** Number of MiB of block files that we're trying to stay below. */ -extern uint64_t nPruneTarget; /** Documentation for argument 'checklevel'. */ extern const std::vector CHECKLEVEL_DOC; @@ -1012,12 +1003,6 @@ bool DumpMempool(const CTxMemPool& pool, FopenFn mockable_fopen_function = fsbri /** Load the mempool from disk. */ bool LoadMempool(CTxMemPool& pool, CChainState& active_chainstate, FopenFn mockable_fopen_function = fsbridge::fopen); -//! Check whether the block associated with this index entry is pruned or not. -inline bool IsBlockPruned(const CBlockIndex* pblockindex) -{ - return (fHavePruned && !(pblockindex->nStatus & BLOCK_HAVE_DATA) && pblockindex->nTx > 0); -} - /** * Return the expected assumeutxo value for a given height, if one exists. * -- cgit v1.2.3 From fa247a327fc7c7cea6bc8f93637b8babd3015ffa Mon Sep 17 00:00:00 2001 From: MarcoFalke Date: Sun, 18 Apr 2021 15:41:08 +0200 Subject: refactor: Move block storage globals to blockstorage However, keep a declaration in validation to make it possible to move smaller chunks to blockstorage without breaking compilation. Also, expose AbortNode in the header. Can be reviewed with --color-moved=dimmed-zebra --color-moved-ws=ignore-all-space --- src/validation.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/validation.h') diff --git a/src/validation.h b/src/validation.h index bd5a0b46e5..7c161a1095 100644 --- a/src/validation.h +++ b/src/validation.h @@ -27,6 +27,7 @@ #include #include #include +#include #include #include @@ -161,6 +162,8 @@ void StopScriptCheckWorkerThreads(); CTransactionRef GetTransaction(const CBlockIndex* const block_index, const CTxMemPool* const mempool, const uint256& hash, const Consensus::Params& consensusParams, uint256& hashBlock); CAmount GetBlockSubsidy(int nHeight, const Consensus::Params& consensusParams); +bool AbortNode(BlockValidationState& state, const std::string& strMessage, const bilingual_str& userMessage = bilingual_str{}); + /** Guess verification progress (as a fraction between 0.0=genesis and 1.0=current tip). */ double GuessVerificationProgress(const ChainTxData& data, const CBlockIndex* pindex); -- cgit v1.2.3 From fa7e64d58615fffea91cd64dc4a2790221ceff0a Mon Sep 17 00:00:00 2001 From: MarcoFalke Date: Sun, 18 Apr 2021 16:31:53 +0200 Subject: move-only: Move constants to blockstorage --- src/validation.h | 2 -- 1 file changed, 2 deletions(-) (limited to 'src/validation.h') diff --git a/src/validation.h b/src/validation.h index 7c161a1095..0e9c6ba198 100644 --- a/src/validation.h +++ b/src/validation.h @@ -71,8 +71,6 @@ static const unsigned int DEFAULT_DESCENDANT_LIMIT = 25; static const unsigned int DEFAULT_DESCENDANT_SIZE_LIMIT = 101; /** Default for -mempoolexpiry, expiration time for mempool transactions in hours */ static const unsigned int DEFAULT_MEMPOOL_EXPIRY = 336; -/** The maximum size of a blk?????.dat file (since 0.8) */ -static const unsigned int MAX_BLOCKFILE_SIZE = 0x8000000; // 128 MiB /** Maximum number of dedicated script-checking threads allowed */ static const int MAX_SCRIPTCHECK_THREADS = 15; /** -par default (number of script-checking threads, 0 = auto) */ -- cgit v1.2.3 From fadafab83379ff10d86ada179c6f9641d19464fe Mon Sep 17 00:00:00 2001 From: MarcoFalke Date: Sun, 18 Apr 2021 17:09:48 +0200 Subject: move-only: Move functions to blockstorage --- src/validation.h | 15 --------------- 1 file changed, 15 deletions(-) (limited to 'src/validation.h') diff --git a/src/validation.h b/src/validation.h index 0e9c6ba198..b6acbc2817 100644 --- a/src/validation.h +++ b/src/validation.h @@ -135,10 +135,6 @@ extern CBlockIndex *pindexBestHeader; /** Documentation for argument 'checklevel'. */ extern const std::vector CHECKLEVEL_DOC; -/** Open a block file (blk?????.dat) */ -FILE* OpenBlockFile(const FlatFilePos &pos, bool fReadOnly = false); -/** Translation to a filesystem path */ -fs::path GetBlockPosFilename(const FlatFilePos &pos); /** Unload database information */ void UnloadBlockIndex(CTxMemPool* mempool, ChainstateManager& chainman); /** Run instances of script checking worker threads */ @@ -165,14 +161,6 @@ bool AbortNode(BlockValidationState& state, const std::string& strMessage, const /** Guess verification progress (as a fraction between 0.0=genesis and 1.0=current tip). */ double GuessVerificationProgress(const ChainTxData& data, const CBlockIndex* pindex); -/** Calculate the amount of disk space the block & undo files currently use */ -uint64_t CalculateCurrentUsage(); - -/** - * Actually unlink the specified files - */ -void UnlinkPrunedFiles(const std::set& setFilesToPrune); - /** Prune block files up to a given height */ void PruneBlockFilesManual(CChainState& active_chainstate, int nManualPruneHeight); @@ -993,9 +981,6 @@ extern VersionBitsCache versionbitscache; */ int32_t ComputeBlockVersion(const CBlockIndex* pindexPrev, const Consensus::Params& params); -/** Get block file info entry for one block file */ -CBlockFileInfo* GetBlockFileInfo(size_t n); - using FopenFn = std::function; /** Dump the mempool to disk. */ -- cgit v1.2.3