aboutsummaryrefslogtreecommitdiff
path: root/src/policy
diff options
context:
space:
mode:
authorJohn Newbery <john@johnnewbery.com>2019-04-02 14:14:58 -0400
committerJohn Newbery <john@johnnewbery.com>2019-04-09 17:53:08 -0400
commit4a75c9d6512a5580e60104103ea11d2cd9586354 (patch)
tree03928bbefeff422d8be4fa400c88be34c1150328 /src/policy
parentfdf8888b6f0c63e8a4cb1459752625e642d6a4dd (diff)
downloadbitcoin-4a75c9d6512a5580e60104103ea11d2cd9586354.tar.xz
[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.
Diffstat (limited to 'src/policy')
-rw-r--r--src/policy/policy.cpp5
-rw-r--r--src/policy/policy.h6
-rw-r--r--src/policy/settings.cpp14
-rw-r--r--src/policy/settings.h17
4 files changed, 34 insertions, 8 deletions
diff --git a/src/policy/policy.cpp b/src/policy/policy.cpp
index d4cc538492..f1e6aadb5a 100644
--- a/src/policy/policy.cpp
+++ b/src/policy/policy.cpp
@@ -10,6 +10,7 @@
#include <consensus/validation.h>
#include <validation.h>
#include <coins.h>
+#include <policy/settings.h>
#include <tinyformat.h>
#include <util/system.h>
#include <util/strencodings.h>
@@ -239,10 +240,6 @@ bool IsWitnessStandard(const CTransaction& tx, const CCoinsViewCache& mapInputs)
return true;
}
-CFeeRate incrementalRelayFee = CFeeRate(DEFAULT_INCREMENTAL_RELAY_FEE);
-CFeeRate dustRelayFee = CFeeRate(DUST_RELAY_TX_FEE);
-unsigned int nBytesPerSigOp = DEFAULT_BYTES_PER_SIGOP;
-
int64_t GetVirtualTransactionSize(int64_t nWeight, int64_t nSigOpCost)
{
return (std::max(nWeight, nSigOpCost * nBytesPerSigOp) + WITNESS_SCALE_FACTOR - 1) / WITNESS_SCALE_FACTOR;
diff --git a/src/policy/policy.h b/src/policy/policy.h
index 3d47ac1267..8660af26de 100644
--- a/src/policy/policy.h
+++ b/src/policy/policy.h
@@ -34,6 +34,8 @@ static const unsigned int DEFAULT_MAX_MEMPOOL_SIZE = 300;
static const unsigned int DEFAULT_INCREMENTAL_RELAY_FEE = 1000;
/** Default for -bytespersigop */
static const unsigned int DEFAULT_BYTES_PER_SIGOP = 20;
+/** Default for -permitbaremultisig */
+static const bool DEFAULT_PERMIT_BAREMULTISIG = true;
/** The maximum number of witness stack items in a standard P2WSH script */
static const unsigned int MAX_STANDARD_P2WSH_STACK_ITEMS = 100;
/** 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)
*/
bool IsWitnessStandard(const CTransaction& tx, const CCoinsViewCache& mapInputs);
-extern CFeeRate incrementalRelayFee;
-extern CFeeRate dustRelayFee;
-extern unsigned int nBytesPerSigOp;
-
/** Compute the virtual transaction size (weight reinterpreted as bytes). */
int64_t GetVirtualTransactionSize(int64_t nWeight, int64_t nSigOpCost);
int64_t GetVirtualTransactionSize(const CTransaction& tx, int64_t nSigOpCost = 0);
diff --git a/src/policy/settings.cpp b/src/policy/settings.cpp
new file mode 100644
index 0000000000..e8e1559407
--- /dev/null
+++ b/src/policy/settings.cpp
@@ -0,0 +1,14 @@
+// Copyright (c) 2009-2010 Satoshi Nakamoto
+// Copyright (c) 2009-2018 The Bitcoin Core developers
+// Distributed under the MIT software license, see the accompanying
+// file COPYING or http://www.opensource.org/licenses/mit-license.php.
+
+#include <policy/settings.h>
+
+#include <policy/feerate.h>
+#include <policy/policy.h>
+
+bool fIsBareMultisigStd = DEFAULT_PERMIT_BAREMULTISIG;
+CFeeRate incrementalRelayFee = CFeeRate(DEFAULT_INCREMENTAL_RELAY_FEE);
+CFeeRate dustRelayFee = CFeeRate(DUST_RELAY_TX_FEE);
+unsigned int nBytesPerSigOp = DEFAULT_BYTES_PER_SIGOP;
diff --git a/src/policy/settings.h b/src/policy/settings.h
new file mode 100644
index 0000000000..1d2a1fb880
--- /dev/null
+++ b/src/policy/settings.h
@@ -0,0 +1,17 @@
+// Copyright (c) 2009-2010 Satoshi Nakamoto
+// Copyright (c) 2009-2018 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_POLICY_SETTINGS_H
+#define BITCOIN_POLICY_SETTINGS_H
+
+class CFeeRate;
+
+// Policy settings which are configurable at runtime.
+extern CFeeRate incrementalRelayFee;
+extern CFeeRate dustRelayFee;
+extern unsigned int nBytesPerSigOp;
+extern bool fIsBareMultisigStd;
+
+#endif // BITCOIN_POLICY_SETTINGS_H