Bitcoin Core  22.99.0
P2P Digital Currency
chainstate.h
Go to the documentation of this file.
1 // Copyright (c) 2021 The Bitcoin Core developers
2 // Distributed under the MIT software license, see the accompanying
3 // file COPYING or http://www.opensource.org/licenses/mit-license.php.
4 
5 #ifndef BITCOIN_NODE_CHAINSTATE_H
6 #define BITCOIN_NODE_CHAINSTATE_H
7 
8 #include <cstdint>
9 #include <functional>
10 #include <optional>
11 
12 class ChainstateManager;
13 class CTxMemPool;
14 namespace Consensus {
15 struct Params;
16 } // namespace Consensus
17 
18 namespace node {
30 };
31 
58 std::optional<ChainstateLoadingError> LoadChainstate(bool fReset,
59  ChainstateManager& chainman,
60  CTxMemPool* mempool,
61  bool fPruneMode,
62  const Consensus::Params& consensus_params,
63  bool fReindexChainState,
64  int64_t nBlockTreeDBCache,
65  int64_t nCoinDBCache,
66  int64_t nCoinCacheUsage,
67  bool block_tree_db_in_memory,
68  bool coins_db_in_memory,
69  std::function<bool()> shutdown_requested = nullptr,
70  std::function<void()> coins_error_cb = nullptr);
71 
76 };
77 
78 std::optional<ChainstateLoadVerifyError> VerifyLoadedChainstate(ChainstateManager& chainman,
79  bool fReset,
80  bool fReindexChainState,
81  const Consensus::Params& consensus_params,
82  unsigned int check_blocks,
83  unsigned int check_level,
84  std::function<int64_t()> get_unix_time_seconds);
85 } // namespace node
86 
87 #endif // BITCOIN_NODE_CHAINSTATE_H
node::ChainstateLoadingError::ERROR_PRUNED_NEEDS_REINDEX
@ ERROR_PRUNED_NEEDS_REINDEX
node::fPruneMode
bool fPruneMode
True if we're running in -prune mode.
Definition: blockstorage.cpp:28
node::ChainstateLoadingError::ERROR_CHAINSTATE_UPGRADE_FAILED
@ ERROR_CHAINSTATE_UPGRADE_FAILED
node::ChainstateLoadVerifyError
ChainstateLoadVerifyError
Definition: chainstate.h:72
CTxMemPool
CTxMemPool stores valid-according-to-the-current-best-chain transactions that may be included in the ...
Definition: txmempool.h:439
node::ChainstateLoadingError::ERROR_GENERIC_BLOCKDB_OPEN_FAILED
@ ERROR_GENERIC_BLOCKDB_OPEN_FAILED
node::VerifyLoadedChainstate
std::optional< ChainstateLoadVerifyError > VerifyLoadedChainstate(ChainstateManager &chainman, bool fReset, bool fReindexChainState, const Consensus::Params &consensus_params, unsigned int check_blocks, unsigned int check_level, std::function< int64_t()> get_unix_time_seconds)
Definition: chainstate.cpp:128
Consensus::Params
Parameters that influence chain consensus.
Definition: params.h:70
node::ChainstateLoadingError::SHUTDOWN_PROBED
@ SHUTDOWN_PROBED
Consensus
Transaction validation functions.
Definition: params.h:12
node::ChainstateLoadingError::ERROR_BAD_GENESIS_BLOCK
@ ERROR_BAD_GENESIS_BLOCK
node::ChainstateLoadVerifyError::ERROR_GENERIC_FAILURE
@ ERROR_GENERIC_FAILURE
node::ChainstateLoadingError::ERROR_LOAD_GENESIS_BLOCK_FAILED
@ ERROR_LOAD_GENESIS_BLOCK_FAILED
node::ChainstateLoadingError::ERROR_REPLAYBLOCKS_FAILED
@ ERROR_REPLAYBLOCKS_FAILED
node::ChainstateLoadingError::ERROR_BLOCKS_WITNESS_INSUFFICIENTLY_VALIDATED
@ ERROR_BLOCKS_WITNESS_INSUFFICIENTLY_VALIDATED
ChainstateManager
Provides an interface for creating and interacting with one or two chainstates: an IBD chainstate gen...
Definition: validation.h:761
Params
const CChainParams & Params()
Return the currently selected parameters.
Definition: chainparams.cpp:561
node
Definition: init.h:22
node::ChainstateLoadingError::ERROR_LOADCHAINTIP_FAILED
@ ERROR_LOADCHAINTIP_FAILED
node::ChainstateLoadVerifyError::ERROR_BLOCK_FROM_FUTURE
@ ERROR_BLOCK_FROM_FUTURE
node::ChainstateLoadingError::ERROR_LOADING_BLOCK_DB
@ ERROR_LOADING_BLOCK_DB
node::ChainstateLoadVerifyError::ERROR_CORRUPTED_BLOCK_DB
@ ERROR_CORRUPTED_BLOCK_DB
node::ChainstateLoadingError
ChainstateLoadingError
Definition: chainstate.h:19
node::LoadChainstate
std::optional< ChainstateLoadingError > LoadChainstate(bool fReset, ChainstateManager &chainman, CTxMemPool *mempool, bool fPruneMode, const Consensus::Params &consensus_params, bool fReindexChainState, int64_t nBlockTreeDBCache, int64_t nCoinDBCache, int64_t nCoinCacheUsage, bool block_tree_db_in_memory, bool coins_db_in_memory, std::function< bool()> shutdown_requested, std::function< void()> coins_error_cb)
This sequence can have 4 types of outcomes:
Definition: chainstate.cpp:12