forked from bitcoin/bitcoin
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Expand file tree
/
Copy pathchainstate.h
More file actions
95 lines (82 loc) · 3.32 KB
/
Copy pathchainstate.h
File metadata and controls
95 lines (82 loc) · 3.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
// Copyright (c) 2021 The Bitcoin Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#ifndef BITCOIN_NODE_CHAINSTATE_H
#define BITCOIN_NODE_CHAINSTATE_H
#include <llmq/options.h>
#include <util/fs.h>
#include <validation.h>
#include <cstdint>
#include <functional>
#include <memory>
#include <optional>
#include <string>
#include <tuple>
class CChainstateHelper;
class CDeterministicMNManager;
class CEvoDB;
class ChainstateManager;
class CMasternodeSync;
class CTxMemPool;
struct LLMQContext;
namespace chainlock { class Chainlocks; }
namespace llmq { class CInstantSendManager; }
namespace node {
struct CacheSizes;
struct ChainstateLoadOptions {
CTxMemPool* mempool{nullptr};
llmq::CInstantSendManager* isman{nullptr};
chainlock::Chainlocks* chainlocks{nullptr};
const CMasternodeSync* mn_sync{nullptr};
fs::path data_dir;
bool block_tree_db_in_memory{false};
bool coins_db_in_memory{false};
bool dash_dbs_in_memory{false};
bool reindex{false};
bool reindex_chainstate{false};
bool prune{false};
int8_t bls_threads{llmq::DEFAULT_BLSCHECK_THREADS};
int16_t worker_count{llmq::DEFAULT_WORKER_COUNT};
int64_t max_recsigs_age{llmq::DEFAULT_MAX_RECOVERED_SIGS_AGE};
int64_t check_blocks{DEFAULT_CHECKBLOCKS};
int64_t check_level{DEFAULT_CHECKLEVEL};
std::function<bool()> check_interrupt;
std::function<void()> coins_error_cb;
};
//! Chainstate load status. Simple applications can just check for the success
//! case, and treat other cases as errors. More complex applications may want to
//! try reindexing in the generic failure case, and pass an interrupt callback
//! and exit cleanly in the interrupted case.
enum class ChainstateLoadStatus {
SUCCESS,
FAILURE, //!< Generic failure which reindexing may fix
FAILURE_FATAL, //!< Fatal error which should not prompt to reindex
FAILURE_INCOMPATIBLE_DB,
INTERRUPTED,
};
//! Chainstate load status code and optional error string.
using ChainstateLoadResult = std::tuple<ChainstateLoadStatus, bilingual_str>;
/** This sequence can have 4 types of outcomes:
*
* 1. Success
* 2. Shutdown requested
* - nothing failed but a shutdown was triggered in the middle of the
* sequence
* 3. Soft failure
* - a failure that might be recovered from with a reindex
* 4. Hard failure
* - a failure that definitively cannot be recovered from with a reindex
*
* LoadChainstate returns a (status code, error string) tuple.
*
* The llmq_ctx and chain_helper arguments are outputs: any instance they hold
* is destroyed and replaced with a freshly constructed one.
*/
ChainstateLoadResult LoadChainstate(ChainstateManager& chainman, const CacheSizes& cache_sizes,
const ChainstateLoadOptions& options, CEvoDB& evodb,
CDeterministicMNManager& dmnman, std::unique_ptr<LLMQContext>& llmq_ctx,
std::unique_ptr<CChainstateHelper>& chain_helper);
ChainstateLoadResult VerifyLoadedChainstate(ChainstateManager& chainman, const ChainstateLoadOptions& options, CEvoDB& evodb,
std::function<void(bool)> notify_bls_state = nullptr);
} // namespace node
#endif // BITCOIN_NODE_CHAINSTATE_H