/bitcoin/src/node/mempool_args.cpp
Line | Count | Source |
1 | | // Copyright (c) 2022 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 | | #include <node/mempool_args.h> |
6 | | |
7 | | #include <kernel/mempool_limits.h> |
8 | | #include <kernel/mempool_options.h> |
9 | | |
10 | | #include <common/args.h> |
11 | | #include <common/messages.h> |
12 | | #include <consensus/amount.h> |
13 | | #include <kernel/chainparams.h> |
14 | | #include <logging.h> |
15 | | #include <policy/feerate.h> |
16 | | #include <policy/policy.h> |
17 | | #include <tinyformat.h> |
18 | | #include <util/moneystr.h> |
19 | | #include <util/translation.h> |
20 | | |
21 | | #include <chrono> |
22 | | #include <memory> |
23 | | |
24 | | using common::AmountErrMsg; |
25 | | using kernel::MemPoolLimits; |
26 | | using kernel::MemPoolOptions; |
27 | | |
28 | | namespace { |
29 | | void ApplyArgsManOptions(const ArgsManager& argsman, MemPoolLimits& mempool_limits) |
30 | 22.1k | { |
31 | 22.1k | mempool_limits.ancestor_count = argsman.GetIntArg("-limitancestorcount", mempool_limits.ancestor_count); |
32 | | |
33 | 22.1k | if (auto vkb = argsman.GetIntArg("-limitancestorsize")) mempool_limits.ancestor_size_vbytes = *vkb * 1'000; Branch (33:14): [True: 0, False: 22.1k]
|
34 | | |
35 | 22.1k | mempool_limits.descendant_count = argsman.GetIntArg("-limitdescendantcount", mempool_limits.descendant_count); |
36 | | |
37 | 22.1k | if (auto vkb = argsman.GetIntArg("-limitdescendantsize")) mempool_limits.descendant_size_vbytes = *vkb * 1'000; Branch (37:14): [True: 0, False: 22.1k]
|
38 | 22.1k | } |
39 | | } |
40 | | |
41 | | util::Result<void> ApplyArgsManOptions(const ArgsManager& argsman, const CChainParams& chainparams, MemPoolOptions& mempool_opts) |
42 | 22.1k | { |
43 | 22.1k | mempool_opts.check_ratio = argsman.GetIntArg("-checkmempool", mempool_opts.check_ratio); |
44 | | |
45 | 22.1k | if (auto mb = argsman.GetIntArg("-maxmempool")) mempool_opts.max_size_bytes = *mb * 1'000'000; Branch (45:14): [True: 22.1k, False: 0]
|
46 | | |
47 | 22.1k | if (auto hours = argsman.GetIntArg("-mempoolexpiry")) mempool_opts.expiry = std::chrono::hours{*hours}; Branch (47:14): [True: 0, False: 22.1k]
|
48 | | |
49 | | // incremental relay fee sets the minimum feerate increase necessary for replacement in the mempool |
50 | | // and the amount the mempool min fee increases above the feerate of txs evicted due to mempool limiting. |
51 | 22.1k | if (const auto arg{argsman.GetArg("-incrementalrelayfee")}) { Branch (51:20): [True: 0, False: 22.1k]
|
52 | 0 | if (std::optional<CAmount> inc_relay_fee = ParseMoney(*arg)) { Branch (52:36): [True: 0, False: 0]
|
53 | 0 | mempool_opts.incremental_relay_feerate = CFeeRate{inc_relay_fee.value()}; |
54 | 0 | } else { |
55 | 0 | return util::Error{AmountErrMsg("incrementalrelayfee", *arg)}; |
56 | 0 | } |
57 | 0 | } |
58 | | |
59 | 22.1k | if (const auto arg{argsman.GetArg("-minrelaytxfee")}) { Branch (59:20): [True: 0, False: 22.1k]
|
60 | 0 | if (std::optional<CAmount> min_relay_feerate = ParseMoney(*arg)) { Branch (60:36): [True: 0, False: 0]
|
61 | | // High fee check is done afterward in CWallet::Create() |
62 | 0 | mempool_opts.min_relay_feerate = CFeeRate{min_relay_feerate.value()}; |
63 | 0 | } else { |
64 | 0 | return util::Error{AmountErrMsg("minrelaytxfee", *arg)}; |
65 | 0 | } |
66 | 22.1k | } else if (mempool_opts.incremental_relay_feerate > mempool_opts.min_relay_feerate) { Branch (66:16): [True: 0, False: 22.1k]
|
67 | | // Allow only setting incremental fee to control both |
68 | 0 | mempool_opts.min_relay_feerate = mempool_opts.incremental_relay_feerate; |
69 | 0 | LogPrintf("Increasing minrelaytxfee to %s to match incrementalrelayfee\n", mempool_opts.min_relay_feerate.ToString()); |
70 | 0 | } |
71 | | |
72 | | // Feerate used to define dust. Shouldn't be changed lightly as old |
73 | | // implementations may inadvertently create non-standard transactions |
74 | 22.1k | if (const auto arg{argsman.GetArg("-dustrelayfee")}) { Branch (74:20): [True: 0, False: 22.1k]
|
75 | 0 | if (std::optional<CAmount> parsed = ParseMoney(*arg)) { Branch (75:36): [True: 0, False: 0]
|
76 | 0 | mempool_opts.dust_relay_feerate = CFeeRate{parsed.value()}; |
77 | 0 | } else { |
78 | 0 | return util::Error{AmountErrMsg("dustrelayfee", *arg)}; |
79 | 0 | } |
80 | 0 | } |
81 | | |
82 | 22.1k | mempool_opts.permit_bare_multisig = argsman.GetBoolArg("-permitbaremultisig", DEFAULT_PERMIT_BAREMULTISIG); |
83 | | |
84 | 22.1k | if (argsman.GetBoolArg("-datacarrier", DEFAULT_ACCEPT_DATACARRIER)) { Branch (84:9): [True: 22.1k, False: 0]
|
85 | 22.1k | mempool_opts.max_datacarrier_bytes = argsman.GetIntArg("-datacarriersize", MAX_OP_RETURN_RELAY); |
86 | 22.1k | } else { |
87 | 0 | mempool_opts.max_datacarrier_bytes = std::nullopt; |
88 | 0 | } |
89 | | |
90 | 22.1k | mempool_opts.require_standard = !argsman.GetBoolArg("-acceptnonstdtxn", DEFAULT_ACCEPT_NON_STD_TXN); |
91 | 22.1k | if (!chainparams.IsTestChain() && !mempool_opts.require_standard) { Branch (91:9): [True: 0, False: 22.1k]
Branch (91:39): [True: 0, False: 0]
|
92 | 0 | return util::Error{Untranslated(strprintf("acceptnonstdtxn is not currently supported for %s chain", chainparams.GetChainTypeString()))}; |
93 | 0 | } |
94 | | |
95 | 22.1k | mempool_opts.persist_v1_dat = argsman.GetBoolArg("-persistmempoolv1", mempool_opts.persist_v1_dat); |
96 | | |
97 | 22.1k | ApplyArgsManOptions(argsman, mempool_opts.limits); |
98 | | |
99 | 22.1k | return {}; |
100 | 22.1k | } |