diff --git a/CMakeLists.txt b/CMakeLists.txt index 17c8ea338ebfb..b0407eca6373d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -366,7 +366,6 @@ target_include_directories(ZEROCOIN_A PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/src set(COMMON_SOURCES ./src/allocators.cpp - ./src/amount.cpp ./src/base58.cpp ./src/bip38.cpp ./src/consensus/params.cpp @@ -390,6 +389,7 @@ set(COMMON_SOURCES ./src/keystore.cpp ./src/netaddress.cpp ./src/netbase.cpp + ./src/policy/feerate.cpp ./src/protocol.cpp ./src/pubkey.cpp ./src/scheduler.cpp diff --git a/src/Makefile.am b/src/Makefile.am index 37c4ecc421366..a7028959d9547 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -221,6 +221,7 @@ BITCOIN_CORE_H = \ netbase.h \ netmessagemaker.h \ noui.h \ + policy/feerate.h \ policy/fees.h \ policy/policy.h \ optional.h \ @@ -477,7 +478,6 @@ libbitcoin_common_a_CPPFLAGS = $(AM_CPPFLAGS) $(BITCOIN_INCLUDES) libbitcoin_common_a_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) libbitcoin_common_a_SOURCES = \ allocators.cpp \ - amount.cpp \ base58.cpp \ bip38.cpp \ chainparams.cpp \ @@ -497,6 +497,7 @@ libbitcoin_common_a_SOURCES = \ keystore.cpp \ netaddress.cpp \ netbase.cpp \ + policy/feerate.cpp \ protocol.cpp \ pubkey.cpp \ scheduler.cpp \ diff --git a/src/amount.h b/src/amount.h index 1fe09b59645e6..1f3bc361031b9 100644 --- a/src/amount.h +++ b/src/amount.h @@ -1,18 +1,13 @@ // Copyright (c) 2009-2010 Satoshi Nakamoto -// Copyright (c) 2009-2014 The Bitcoin developers +// Copyright (c) 2009-2017 The Bitcoin developers // Copyright (c) 2017-2020 The PIVX developers // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. -#ifndef BITCOIN_AMOUNT_H -#define BITCOIN_AMOUNT_H +#ifndef PIVX_AMOUNT_H +#define PIVX_AMOUNT_H -#include "serialize.h" - -#include -#include - -extern const std::string CURRENCY_UNIT; +#include /** Amount in PIV (Can be negative) */ typedef int64_t CAmount; @@ -20,37 +15,4 @@ typedef int64_t CAmount; static const CAmount COIN = 100000000; static const CAmount CENT = 1000000; -/** - * Fee rate in PIV per kilobyte: CAmount / kB - */ -class CFeeRate -{ -private: - CAmount nSatoshisPerK; // unit is satoshis-per-1,000-bytes -public: - CFeeRate() : nSatoshisPerK(0) {} - explicit CFeeRate(const CAmount& _nSatoshisPerK) : nSatoshisPerK(_nSatoshisPerK) {} - CFeeRate(const CAmount& nFeePaid, size_t nSize); - CFeeRate(const CFeeRate& other) { nSatoshisPerK = other.nSatoshisPerK; } - - CAmount GetFee(size_t size) const; // unit returned is satoshis - CAmount GetFeePerK() const { return GetFee(1000); } // satoshis-per-1000-bytes - - friend bool operator<(const CFeeRate& a, const CFeeRate& b) { return a.nSatoshisPerK < b.nSatoshisPerK; } - friend bool operator>(const CFeeRate& a, const CFeeRate& b) { return a.nSatoshisPerK > b.nSatoshisPerK; } - friend bool operator==(const CFeeRate& a, const CFeeRate& b) { return a.nSatoshisPerK == b.nSatoshisPerK; } - friend bool operator<=(const CFeeRate& a, const CFeeRate& b) { return a.nSatoshisPerK <= b.nSatoshisPerK; } - friend bool operator>=(const CFeeRate& a, const CFeeRate& b) { return a.nSatoshisPerK >= b.nSatoshisPerK; } - CFeeRate& operator+=(const CFeeRate& a) { nSatoshisPerK += a.nSatoshisPerK; return *this; } - std::string ToString() const; - - ADD_SERIALIZE_METHODS; - - template - inline void SerializationOp(Stream& s, Operation ser_action) - { - READWRITE(nSatoshisPerK); - } -}; - -#endif // BITCOIN_AMOUNT_H +#endif // PIVX_AMOUNT_H diff --git a/src/coincontrol.h b/src/coincontrol.h index 4a72a4fa8aef2..3169f5a0a1f5c 100644 --- a/src/coincontrol.h +++ b/src/coincontrol.h @@ -7,6 +7,7 @@ #ifndef BITCOIN_COINCONTROL_H #define BITCOIN_COINCONTROL_H +#include "policy/feerate.h" #include "primitives/transaction.h" #include "script/standard.h" diff --git a/src/init.cpp b/src/init.cpp index aadf307743fd0..419414f72b0eb 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -34,6 +34,7 @@ #include "miner.h" #include "netbase.h" #include "net_processing.h" +#include "policy/feerate.h" #include "policy/policy.h" #include "reverse_iterate.h" #include "rpc/register.h" diff --git a/src/memusage.h b/src/memusage.h index 364cedbf33ccc..b06421a750173 100644 --- a/src/memusage.h +++ b/src/memusage.h @@ -5,9 +5,12 @@ #ifndef BITCOIN_MEMUSAGE_H #define BITCOIN_MEMUSAGE_H +#include "prevector.h" + #include #include +#include #include #include #include diff --git a/src/miner.cpp b/src/miner.cpp index 00b5e545c1b5f..5082c9c1d1de2 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -19,6 +19,7 @@ #include "masternode-sync.h" #include "net.h" #include "pow.h" +#include "policy/feerate.h" #include "primitives/block.h" #include "primitives/transaction.h" #include "timedata.h" diff --git a/src/amount.cpp b/src/policy/feerate.cpp similarity index 86% rename from src/amount.cpp rename to src/policy/feerate.cpp index 31c357794eb01..4ea9f85bc9ed3 100644 --- a/src/amount.cpp +++ b/src/policy/feerate.cpp @@ -1,10 +1,10 @@ // Copyright (c) 2009-2010 Satoshi Nakamoto -// Copyright (c) 2009-2014 The Bitcoin developers -// Copyright (c) 2017-2019 The PIVX developers +// Copyright (c) 2009-2017 The Bitcoin developers +// Copyright (c) 2017-2020 The PIVX developers // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. -#include "amount.h" +#include "feerate.h" #include "tinyformat.h" diff --git a/src/policy/feerate.h b/src/policy/feerate.h new file mode 100644 index 0000000000000..db9ac37fc8984 --- /dev/null +++ b/src/policy/feerate.h @@ -0,0 +1,49 @@ +// Copyright (c) 2009-2017 The Bitcoin Core developers +// Copyright (c) 2017-2020 The PIVX developers +// Distributed under the MIT software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + +#ifndef PIVX_POLICY_FEERATE_H +#define PIVX_POLICY_FEERATE_H + +#include "amount.h" +#include "serialize.h" + +#include + +extern const std::string CURRENCY_UNIT; + +/** + * Fee rate in PIV per kilobyte: CAmount / kB + */ +class CFeeRate +{ +private: + CAmount nSatoshisPerK; // unit is satoshis-per-1,000-bytes +public: + CFeeRate() : nSatoshisPerK(0) {} + explicit CFeeRate(const CAmount& _nSatoshisPerK) : nSatoshisPerK(_nSatoshisPerK) {} + CFeeRate(const CAmount& nFeePaid, size_t nSize); + CFeeRate(const CFeeRate& other) { nSatoshisPerK = other.nSatoshisPerK; } + + CAmount GetFee(size_t size) const; // unit returned is satoshis + CAmount GetFeePerK() const { return GetFee(1000); } // satoshis-per-1000-bytes + + friend bool operator<(const CFeeRate& a, const CFeeRate& b) { return a.nSatoshisPerK < b.nSatoshisPerK; } + friend bool operator>(const CFeeRate& a, const CFeeRate& b) { return a.nSatoshisPerK > b.nSatoshisPerK; } + friend bool operator==(const CFeeRate& a, const CFeeRate& b) { return a.nSatoshisPerK == b.nSatoshisPerK; } + friend bool operator<=(const CFeeRate& a, const CFeeRate& b) { return a.nSatoshisPerK <= b.nSatoshisPerK; } + friend bool operator>=(const CFeeRate& a, const CFeeRate& b) { return a.nSatoshisPerK >= b.nSatoshisPerK; } + CFeeRate& operator+=(const CFeeRate& a) { nSatoshisPerK += a.nSatoshisPerK; return *this; } + std::string ToString() const; + + ADD_SERIALIZE_METHODS; + + template + inline void SerializationOp(Stream& s, Operation ser_action) + { + READWRITE(nSatoshisPerK); + } +}; + +#endif // PIVX_POLICY_FEERATE_H diff --git a/src/policy/fees.h b/src/policy/fees.h index fd5736d03338b..51c3e97f11e92 100644 --- a/src/policy/fees.h +++ b/src/policy/fees.h @@ -6,6 +6,7 @@ #define BITCOIN_POLICYESTIMATOR_H #include "amount.h" +#include "feerate.h" #include "uint256.h" #include diff --git a/src/policy/policy.h b/src/policy/policy.h index e6b0fd800d099..43543613992a1 100644 --- a/src/policy/policy.h +++ b/src/policy/policy.h @@ -7,6 +7,7 @@ #define BITCOIN_POLICY_H #include "consensus/consensus.h" +#include "feerate.h" #include "script/interpreter.h" #include "script/standard.h" diff --git a/src/qt/bitcoinunits.cpp b/src/qt/bitcoinunits.cpp index d227b725daf18..da95deb9e6bc4 100644 --- a/src/qt/bitcoinunits.cpp +++ b/src/qt/bitcoinunits.cpp @@ -6,6 +6,7 @@ #include "bitcoinunits.h" #include "chainparams.h" +#include "policy/feerate.h" #include "primitives/transaction.h" #include diff --git a/src/qt/pivx/sendcustomfeedialog.h b/src/qt/pivx/sendcustomfeedialog.h index b7c794698f955..b428b71380ffa 100644 --- a/src/qt/pivx/sendcustomfeedialog.h +++ b/src/qt/pivx/sendcustomfeedialog.h @@ -5,7 +5,7 @@ #ifndef SENDCUSTOMFEEDIALOG_H #define SENDCUSTOMFEEDIALOG_H -#include "amount.h" +#include "policy/feerate.h" #include "qt/pivx/focuseddialog.h" #include "qt/pivx/snackbar.h" diff --git a/src/rpc/blockchain.cpp b/src/rpc/blockchain.cpp index 9a7bee9fa4b6d..0b45bc349206b 100644 --- a/src/rpc/blockchain.cpp +++ b/src/rpc/blockchain.cpp @@ -12,6 +12,7 @@ #include "kernel.h" #include "masternode-budget.h" #include "masternodeman.h" +#include "policy/feerate.h" #include "policy/policy.h" #include "rpc/server.h" #include "sync.h" @@ -1651,4 +1652,4 @@ void RegisterBlockchainRPCCommands(CRPCTable &tableRPC) { for (unsigned int vcidx = 0; vcidx < ARRAYLEN(commands); vcidx++) tableRPC.appendCommand(commands[vcidx].name, &commands[vcidx]); -} \ No newline at end of file +} diff --git a/src/test/mempool_tests.cpp b/src/test/mempool_tests.cpp index ae1220f3c330f..0a863a6a97c32 100644 --- a/src/test/mempool_tests.cpp +++ b/src/test/mempool_tests.cpp @@ -4,6 +4,7 @@ #include "test/test_pivx.h" +#include "policy/feerate.h" #include "txmempool.h" #include "util.h" diff --git a/src/test/policyestimator_tests.cpp b/src/test/policyestimator_tests.cpp index 1ce118cf3696e..7c1bbea416359 100644 --- a/src/test/policyestimator_tests.cpp +++ b/src/test/policyestimator_tests.cpp @@ -2,6 +2,7 @@ // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. +#include "policy/feerate.h" #include "policy/fees.h" #include "txmempool.h" #include "uint256.h" diff --git a/src/txmempool.h b/src/txmempool.h index 3f128c1287dd7..493cb6f3ac7ea 100644 --- a/src/txmempool.h +++ b/src/txmempool.h @@ -13,6 +13,7 @@ #include "amount.h" #include "coins.h" +#include "policy/feerate.h" #include "primitives/transaction.h" #include "sync.h" #include "random.h" diff --git a/src/validation.h b/src/validation.h index 9de1bd96a4672..c524aa2256662 100644 --- a/src/validation.h +++ b/src/validation.h @@ -21,6 +21,7 @@ #include "consensus/validation.h" #include "fs.h" #include "moneysupply.h" +#include "policy/feerate.h" #include "script/script_error.h" #include "sync.h" #include "txmempool.h" diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 767777025e9b9..7e8bb88fc7fc4 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -14,6 +14,7 @@ #include "key_io.h" #include "masternode-sync.h" #include "net.h" +#include "policy/feerate.h" #include "rpc/server.h" #include "timedata.h" #include "util.h" diff --git a/src/wallet/wallet.h b/src/wallet/wallet.h index bba34556e3d95..52b1ecc7a204a 100644 --- a/src/wallet/wallet.h +++ b/src/wallet/wallet.h @@ -18,6 +18,7 @@ #include "key.h" #include "keystore.h" #include "pairresult.h" +#include "policy/feerate.h" #include "primitives/block.h" #include "primitives/transaction.h" #include "sapling/address.hpp"