mempool_options.h raw
1 // Copyright (c) 2022 The Limenka developers
2 // Distributed under the MIT software license, see the accompanying
3 // file COPYING or http://www.opensource.org/licenses/mit-license.php.
4 #ifndef LIMENKA_KERNEL_MEMPOOL_OPTIONS_H
5 #define LIMENKA_KERNEL_MEMPOOL_OPTIONS_H
6
7 #include <kernel/mempool_limits.h>
8
9 #include <policy/feerate.h>
10 #include <policy/policy.h>
11
12 #include <chrono>
13 #include <cstdint>
14 #include <optional>
15
16 class CBlockPolicyEstimator;
17 class CScheduler;
18 class ValidationSignals;
19
20 enum class RBFPolicy { Never, OptIn, Always };
21 enum class TRUCPolicy { Reject, Accept, Enforce };
22
23 /** Default for -maxmempool, maximum megabytes of mempool memory usage */
24 static constexpr unsigned int DEFAULT_MAX_MEMPOOL_SIZE_MB{300};
25 /** Default for -maxmempool when blocksonly is set */
26 static constexpr unsigned int DEFAULT_BLOCKSONLY_MAX_MEMPOOL_SIZE_MB{5};
27 /** Default for -mempoolexpiry, expiration time for mempool transactions in hours */
28 static constexpr unsigned int DEFAULT_MEMPOOL_EXPIRY_HOURS{336};
29 /** Default for -minrelaycoinblocks */
30 static constexpr uint64_t DEFAULT_MINRELAYCOINBLOCKS{0};
31 /** Default for -minrelaymaturity */
32 static constexpr int DEFAULT_MINRELAYMATURITY{0};
33 /** Default for -mempoolreplacement; must update docs in init.cpp manually */
34 static constexpr RBFPolicy DEFAULT_MEMPOOL_RBF_POLICY{RBFPolicy::Always};
35 /** Default for -mempooltruc; must update docs in init.cpp manually */
36 static constexpr TRUCPolicy DEFAULT_MEMPOOL_TRUC_POLICY{TRUCPolicy::Accept};
37 /** Whether to fall back to legacy V1 serialization when writing mempool.dat */
38 static constexpr bool DEFAULT_PERSIST_V1_DAT{false};
39 /** Default for -acceptnonstddatacarrier */
40 static constexpr bool DEFAULT_ACCEPT_NON_STD_DATACARRIER{false};
41 /** Default for -acceptnonstdtxn */
42 static constexpr bool DEFAULT_ACCEPT_NON_STD_TXN{false};
43 /** Default for -acceptunknownwitness */
44 static constexpr bool DEFAULT_ACCEPTUNKNOWNWITNESS{true};
45
46 namespace kernel {
47 /**
48 * Options struct containing options for constructing a CTxMemPool. Default
49 * constructor populates the struct with sane default values which can be
50 * modified.
51 *
52 * Most of the time, this struct should be referenced as CTxMemPool::Options.
53 */
54 struct MemPoolOptions {
55 /* Used to estimate appropriate transaction fees. */
56 CBlockPolicyEstimator* estimator{nullptr};
57 CScheduler* scheduler{nullptr};
58 /* The ratio used to determine how often sanity checks will run. */
59 int check_ratio{0};
60 int64_t max_size_bytes{DEFAULT_MAX_MEMPOOL_SIZE_MB * 1'000'000};
61 std::chrono::seconds expiry{std::chrono::hours{DEFAULT_MEMPOOL_EXPIRY_HOURS}};
62 uint64_t minrelaycoinblocks{DEFAULT_MINRELAYCOINBLOCKS};
63 int minrelaymaturity{DEFAULT_MINRELAYMATURITY};
64 CFeeRate incremental_relay_feerate{DEFAULT_INCREMENTAL_RELAY_FEE};
65 /** A fee rate smaller than this is considered zero fee (for relaying, mining and transaction creation) */
66 CFeeRate min_relay_feerate{DEFAULT_MIN_RELAY_TX_FEE};
67 CFeeRate dust_relay_feerate{DUST_RELAY_TX_FEE};
68 CFeeRate dust_relay_feerate_floor{DUST_RELAY_TX_FEE};
69 /** Negative for a target number of blocks, positive for target kB into current mempool. */
70 int32_t dust_relay_target{0};
71 /** Multiplier for dustdynamic assignments, in thousandths. */
72 int dust_relay_multiplier{DEFAULT_DUST_RELAY_MULTIPLIER};
73 unsigned int maxtxlegacysigops{MAX_TX_LEGACY_SIGOPS};
74 /**
75 * A data carrying output is an unspendable output containing data. The script
76 * type is designated as TxoutType::NULL_DATA.
77 *
78 * Maximum size of TxoutType::NULL_DATA scripts that this node considers standard.
79 * If nullopt, any size is nonstandard.
80 */
81 std::optional<unsigned> max_datacarrier_bytes{DEFAULT_ACCEPT_DATACARRIER ? std::optional{MAX_OP_RETURN_RELAY} : std::nullopt};
82 bool datacarrier_fullcount{DEFAULT_DATACARRIER_FULLCOUNT};
83 bool permitbaredatacarrier{DEFAULT_PERMITBAREDATACARRIER};
84 bool permitbareanchor{DEFAULT_PERMITBAREANCHOR};
85 bool permit_bare_pubkey{DEFAULT_PERMIT_BAREPUBKEY};
86 unsigned int max_op_return_outputs{DEFAULT_MAX_OP_RETURN_OUTPUTS};
87 unsigned int taproot_witness_limit{DEFAULT_TAPROOT_WITNESS_LIMIT};
88 bool reject_taproot{false};
89 bool permit_bare_multisig{DEFAULT_PERMIT_BAREMULTISIG};
90 bool reject_parasites{DEFAULT_REJECT_PARASITES};
91 bool reject_tokens{DEFAULT_REJECT_TOKENS};
92 bool subdustfeepenalty{DEFAULT_SUBDUSTFEEPENALTY};
93 bool accept_non_std_datacarrier{DEFAULT_ACCEPT_NON_STD_DATACARRIER};
94 bool require_standard{true};
95 bool acceptunknownwitness{DEFAULT_ACCEPTUNKNOWNWITNESS};
96 RBFPolicy rbf_policy{DEFAULT_MEMPOOL_RBF_POLICY};
97 TRUCPolicy truc_policy{DEFAULT_MEMPOOL_TRUC_POLICY};
98 bool permitephemeral_anchor{DEFAULT_PERMITEPHEMERAL_ANCHOR};
99 bool permitephemeral_send{DEFAULT_PERMITEPHEMERAL_SEND};
100 bool permitephemeral_dust{DEFAULT_PERMITEPHEMERAL_DUST};
101 bool persist_v1_dat{DEFAULT_PERSIST_V1_DAT};
102 MemPoolLimits limits{};
103
104 ValidationSignals* signals{nullptr};
105 };
106 } // namespace kernel
107
108 #endif // LIMENKA_KERNEL_MEMPOOL_OPTIONS_H
109