Skip to content

Commit 4a75c9d

Browse files
committed
[build] Move policy settings to new src/policy/settings unit
This moves the following policy settings functions and globals to a new src/policy/settings unit in lib_server: - `incrementalRelayFee` - `dustRelayFee` - `nBytesPerSigOp` - `fIsBareMultisigStd` These settings are only required by the node and should not be accessed by other libraries.
1 parent fdf8888 commit 4a75c9d

15 files changed

+47
-14
lines changed

src/Makefile.am

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,7 @@ BITCOIN_CORE_H = \
164164
policy/fees.h \
165165
policy/policy.h \
166166
policy/rbf.h \
167+
policy/settings.h \
167168
pow.h \
168169
protocol.h \
169170
psbt.h \
@@ -269,8 +270,8 @@ libbitcoin_server_a_SOURCES = \
269270
noui.cpp \
270271
outputtype.cpp \
271272
policy/fees.cpp \
272-
policy/policy.cpp \
273273
policy/rbf.cpp \
274+
policy/settings.cpp \
274275
pow.cpp \
275276
rest.cpp \
276277
rpc/blockchain.cpp \
@@ -436,6 +437,7 @@ libbitcoin_common_a_SOURCES = \
436437
netaddress.cpp \
437438
netbase.cpp \
438439
policy/feerate.cpp \
440+
policy/policy.cpp \
439441
protocol.cpp \
440442
psbt.cpp \
441443
scheduler.cpp \

src/init.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
#include <policy/feerate.h>
3232
#include <policy/fees.h>
3333
#include <policy/policy.h>
34+
#include <policy/settings.h>
3435
#include <rpc/server.h>
3536
#include <rpc/register.h>
3637
#include <rpc/blockchain.h>

src/interfaces/chain.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#include <policy/fees.h>
1414
#include <policy/policy.h>
1515
#include <policy/rbf.h>
16+
#include <policy/settings.h>
1617
#include <primitives/block.h>
1718
#include <primitives/transaction.h>
1819
#include <protocol.h>

src/interfaces/node.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include <policy/feerate.h>
2121
#include <policy/fees.h>
2222
#include <policy/policy.h>
23+
#include <policy/settings.h>
2324
#include <primitives/block.h>
2425
#include <rpc/server.h>
2526
#include <scheduler.h>

src/policy/policy.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include <consensus/validation.h>
1111
#include <validation.h>
1212
#include <coins.h>
13+
#include <policy/settings.h>
1314
#include <tinyformat.h>
1415
#include <util/system.h>
1516
#include <util/strencodings.h>
@@ -239,10 +240,6 @@ bool IsWitnessStandard(const CTransaction& tx, const CCoinsViewCache& mapInputs)
239240
return true;
240241
}
241242

242-
CFeeRate incrementalRelayFee = CFeeRate(DEFAULT_INCREMENTAL_RELAY_FEE);
243-
CFeeRate dustRelayFee = CFeeRate(DUST_RELAY_TX_FEE);
244-
unsigned int nBytesPerSigOp = DEFAULT_BYTES_PER_SIGOP;
245-
246243
int64_t GetVirtualTransactionSize(int64_t nWeight, int64_t nSigOpCost)
247244
{
248245
return (std::max(nWeight, nSigOpCost * nBytesPerSigOp) + WITNESS_SCALE_FACTOR - 1) / WITNESS_SCALE_FACTOR;

src/policy/policy.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ static const unsigned int DEFAULT_MAX_MEMPOOL_SIZE = 300;
3434
static const unsigned int DEFAULT_INCREMENTAL_RELAY_FEE = 1000;
3535
/** Default for -bytespersigop */
3636
static const unsigned int DEFAULT_BYTES_PER_SIGOP = 20;
37+
/** Default for -permitbaremultisig */
38+
static const bool DEFAULT_PERMIT_BAREMULTISIG = true;
3739
/** The maximum number of witness stack items in a standard P2WSH script */
3840
static const unsigned int MAX_STANDARD_P2WSH_STACK_ITEMS = 100;
3941
/** The maximum size of each witness stack item in a standard P2WSH script */
@@ -98,10 +100,6 @@ bool AreInputsStandard(const CTransaction& tx, const CCoinsViewCache& mapInputs)
98100
*/
99101
bool IsWitnessStandard(const CTransaction& tx, const CCoinsViewCache& mapInputs);
100102

101-
extern CFeeRate incrementalRelayFee;
102-
extern CFeeRate dustRelayFee;
103-
extern unsigned int nBytesPerSigOp;
104-
105103
/** Compute the virtual transaction size (weight reinterpreted as bytes). */
106104
int64_t GetVirtualTransactionSize(int64_t nWeight, int64_t nSigOpCost);
107105
int64_t GetVirtualTransactionSize(const CTransaction& tx, int64_t nSigOpCost = 0);

src/policy/settings.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// Copyright (c) 2009-2010 Satoshi Nakamoto
2+
// Copyright (c) 2009-2018 The Bitcoin Core developers
3+
// Distributed under the MIT software license, see the accompanying
4+
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
5+
6+
#include <policy/settings.h>
7+
8+
#include <policy/feerate.h>
9+
#include <policy/policy.h>
10+
11+
bool fIsBareMultisigStd = DEFAULT_PERMIT_BAREMULTISIG;
12+
CFeeRate incrementalRelayFee = CFeeRate(DEFAULT_INCREMENTAL_RELAY_FEE);
13+
CFeeRate dustRelayFee = CFeeRate(DUST_RELAY_TX_FEE);
14+
unsigned int nBytesPerSigOp = DEFAULT_BYTES_PER_SIGOP;

src/policy/settings.h

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// Copyright (c) 2009-2010 Satoshi Nakamoto
2+
// Copyright (c) 2009-2018 The Bitcoin Core developers
3+
// Distributed under the MIT software license, see the accompanying
4+
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
5+
6+
#ifndef BITCOIN_POLICY_SETTINGS_H
7+
#define BITCOIN_POLICY_SETTINGS_H
8+
9+
class CFeeRate;
10+
11+
// Policy settings which are configurable at runtime.
12+
extern CFeeRate incrementalRelayFee;
13+
extern CFeeRate dustRelayFee;
14+
extern unsigned int nBytesPerSigOp;
15+
extern bool fIsBareMultisigStd;
16+
17+
#endif // BITCOIN_POLICY_SETTINGS_H

src/rpc/net.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include <net_processing.h>
1313
#include <netbase.h>
1414
#include <policy/policy.h>
15+
#include <policy/settings.h>
1516
#include <rpc/protocol.h>
1617
#include <rpc/util.h>
1718
#include <sync.h>

src/test/script_p2sh_tests.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include <policy/policy.h>
1111
#include <script/script.h>
1212
#include <script/script_error.h>
13+
#include <policy/settings.h>
1314
#include <script/sign.h>
1415
#include <script/ismine.h>
1516
#include <test/test_bitcoin.h>

0 commit comments

Comments
 (0)