Skip to content

Commit 381a46e

Browse files
committed
Consensus: Policy: MOVEONLY: Move CFeeRate out of the consensus module
...from amount.o to policy/feerate.o Policy, because it moves policy code to the policy directory (common module)
1 parent 330bb5a commit 381a46e

File tree

16 files changed

+70
-46
lines changed

16 files changed

+70
-46
lines changed

src/Makefile.am

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ BITCOIN_CORE_H = \
116116
netbase.h \
117117
netmessagemaker.h \
118118
noui.h \
119+
policy/feerate.h \
119120
policy/fees.h \
120121
policy/policy.h \
121122
policy/rbf.h \
@@ -301,7 +302,6 @@ libbitcoin_consensus_a_SOURCES = \
301302
libbitcoin_common_a_CPPFLAGS = $(AM_CPPFLAGS) $(BITCOIN_INCLUDES)
302303
libbitcoin_common_a_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS)
303304
libbitcoin_common_a_SOURCES = \
304-
amount.cpp \
305305
base58.cpp \
306306
chainparams.cpp \
307307
coins.cpp \
@@ -312,6 +312,7 @@ libbitcoin_common_a_SOURCES = \
312312
keystore.cpp \
313313
netaddress.cpp \
314314
netbase.cpp \
315+
policy/feerate.cpp \
315316
protocol.cpp \
316317
scheduler.cpp \
317318
script/sign.cpp \

src/amount.h

Lines changed: 1 addition & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,14 @@
66
#ifndef BITCOIN_AMOUNT_H
77
#define BITCOIN_AMOUNT_H
88

9-
#include "serialize.h"
10-
11-
#include <stdlib.h>
12-
#include <string>
9+
#include <stdint.h>
1310

1411
/** Amount in satoshis (Can be negative) */
1512
typedef int64_t CAmount;
1613

1714
static const CAmount COIN = 100000000;
1815
static const CAmount CENT = 1000000;
1916

20-
extern const std::string CURRENCY_UNIT;
21-
2217
/** No amount larger than this (in satoshi) is valid.
2318
*
2419
* Note that this constant is *not* the total money supply, which in Bitcoin
@@ -31,42 +26,4 @@ extern const std::string CURRENCY_UNIT;
3126
static const CAmount MAX_MONEY = 21000000 * COIN;
3227
inline bool MoneyRange(const CAmount& nValue) { return (nValue >= 0 && nValue <= MAX_MONEY); }
3328

34-
/**
35-
* Fee rate in satoshis per kilobyte: CAmount / kB
36-
*/
37-
class CFeeRate
38-
{
39-
private:
40-
CAmount nSatoshisPerK; // unit is satoshis-per-1,000-bytes
41-
public:
42-
/** Fee rate of 0 satoshis per kB */
43-
CFeeRate() : nSatoshisPerK(0) { }
44-
explicit CFeeRate(const CAmount& _nSatoshisPerK): nSatoshisPerK(_nSatoshisPerK) { }
45-
/** Constructor for a fee rate in satoshis per kB. The size in bytes must not exceed (2^63 - 1)*/
46-
CFeeRate(const CAmount& nFeePaid, size_t nBytes);
47-
CFeeRate(const CFeeRate& other) { nSatoshisPerK = other.nSatoshisPerK; }
48-
/**
49-
* Return the fee in satoshis for the given size in bytes.
50-
*/
51-
CAmount GetFee(size_t nBytes) const;
52-
/**
53-
* Return the fee in satoshis for a size of 1000 bytes
54-
*/
55-
CAmount GetFeePerK() const { return GetFee(1000); }
56-
friend bool operator<(const CFeeRate& a, const CFeeRate& b) { return a.nSatoshisPerK < b.nSatoshisPerK; }
57-
friend bool operator>(const CFeeRate& a, const CFeeRate& b) { return a.nSatoshisPerK > b.nSatoshisPerK; }
58-
friend bool operator==(const CFeeRate& a, const CFeeRate& b) { return a.nSatoshisPerK == b.nSatoshisPerK; }
59-
friend bool operator<=(const CFeeRate& a, const CFeeRate& b) { return a.nSatoshisPerK <= b.nSatoshisPerK; }
60-
friend bool operator>=(const CFeeRate& a, const CFeeRate& b) { return a.nSatoshisPerK >= b.nSatoshisPerK; }
61-
CFeeRate& operator+=(const CFeeRate& a) { nSatoshisPerK += a.nSatoshisPerK; return *this; }
62-
std::string ToString() const;
63-
64-
ADD_SERIALIZE_METHODS;
65-
66-
template <typename Stream, typename Operation>
67-
inline void SerializationOp(Stream& s, Operation ser_action) {
68-
READWRITE(nSatoshisPerK);
69-
}
70-
};
71-
7229
#endif // BITCOIN_AMOUNT_H

src/init.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#include "netbase.h"
2626
#include "net.h"
2727
#include "net_processing.h"
28+
#include "policy/feerate.h"
2829
#include "policy/fees.h"
2930
#include "policy/policy.h"
3031
#include "rpc/server.h"

src/miner.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include "hash.h"
1616
#include "validation.h"
1717
#include "net.h"
18+
#include "policy/feerate.h"
1819
#include "policy/policy.h"
1920
#include "pow.h"
2021
#include "primitives/transaction.h"

src/net.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include "hash.h"
1515
#include "limitedmap.h"
1616
#include "netaddress.h"
17+
#include "policy/feerate.h"
1718
#include "protocol.h"
1819
#include "random.h"
1920
#include "streams.h"

src/amount.cpp renamed to src/policy/feerate.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// Distributed under the MIT software license, see the accompanying
44
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
55

6-
#include "amount.h"
6+
#include "feerate.h"
77

88
#include "tinyformat.h"
99

src/policy/feerate.h

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
// Copyright (c) 2009-2010 Satoshi Nakamoto
2+
// Copyright (c) 2009-2015 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_FEERATE_H
7+
#define BITCOIN_POLICY_FEERATE_H
8+
9+
#include "amount.h"
10+
#include "serialize.h"
11+
12+
#include <string>
13+
14+
extern const std::string CURRENCY_UNIT;
15+
16+
/**
17+
* Fee rate in satoshis per kilobyte: CAmount / kB
18+
*/
19+
class CFeeRate
20+
{
21+
private:
22+
CAmount nSatoshisPerK; // unit is satoshis-per-1,000-bytes
23+
public:
24+
/** Fee rate of 0 satoshis per kB */
25+
CFeeRate() : nSatoshisPerK(0) { }
26+
explicit CFeeRate(const CAmount& _nSatoshisPerK): nSatoshisPerK(_nSatoshisPerK) { }
27+
/** Constructor for a fee rate in satoshis per kB. The size in bytes must not exceed (2^63 - 1)*/
28+
CFeeRate(const CAmount& nFeePaid, size_t nBytes);
29+
CFeeRate(const CFeeRate& other) { nSatoshisPerK = other.nSatoshisPerK; }
30+
/**
31+
* Return the fee in satoshis for the given size in bytes.
32+
*/
33+
CAmount GetFee(size_t nBytes) const;
34+
/**
35+
* Return the fee in satoshis for a size of 1000 bytes
36+
*/
37+
CAmount GetFeePerK() const { return GetFee(1000); }
38+
friend bool operator<(const CFeeRate& a, const CFeeRate& b) { return a.nSatoshisPerK < b.nSatoshisPerK; }
39+
friend bool operator>(const CFeeRate& a, const CFeeRate& b) { return a.nSatoshisPerK > b.nSatoshisPerK; }
40+
friend bool operator==(const CFeeRate& a, const CFeeRate& b) { return a.nSatoshisPerK == b.nSatoshisPerK; }
41+
friend bool operator<=(const CFeeRate& a, const CFeeRate& b) { return a.nSatoshisPerK <= b.nSatoshisPerK; }
42+
friend bool operator>=(const CFeeRate& a, const CFeeRate& b) { return a.nSatoshisPerK >= b.nSatoshisPerK; }
43+
CFeeRate& operator+=(const CFeeRate& a) { nSatoshisPerK += a.nSatoshisPerK; return *this; }
44+
std::string ToString() const;
45+
46+
ADD_SERIALIZE_METHODS;
47+
48+
template <typename Stream, typename Operation>
49+
inline void SerializationOp(Stream& s, Operation ser_action) {
50+
READWRITE(nSatoshisPerK);
51+
}
52+
};
53+
54+
#endif // BITCOIN_POLICY_FEERATE_H

src/policy/fees.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#define BITCOIN_POLICYESTIMATOR_H
77

88
#include "amount.h"
9+
#include "feerate.h"
910
#include "uint256.h"
1011
#include "random.h"
1112
#include "sync.h"

src/policy/policy.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#define BITCOIN_POLICY_POLICY_H
88

99
#include "consensus/consensus.h"
10+
#include "feerate.h"
1011
#include "script/interpreter.h"
1112
#include "script/standard.h"
1213

src/rpc/blockchain.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#include "consensus/validation.h"
1414
#include "validation.h"
1515
#include "core_io.h"
16+
#include "policy/feerate.h"
1617
#include "policy/policy.h"
1718
#include "primitives/transaction.h"
1819
#include "rpc/server.h"

0 commit comments

Comments
 (0)