forked from bitcoin/bitcoin
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[MOVEONLY] Move CFeeRate out of the consensus module
>>> backports bitcoin/bitcoin@381a46e
- Loading branch information
1 parent
2d86a41
commit 874096e
Showing
20 changed files
with
78 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,56 +1,18 @@ | ||
// 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 <stdlib.h> | ||
#include <string> | ||
|
||
extern const std::string CURRENCY_UNIT; | ||
#include <stdint.h> | ||
|
||
/** Amount in PIV (Can be negative) */ | ||
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 <typename Stream, typename Operation> | ||
inline void SerializationOp(Stream& s, Operation ser_action) | ||
{ | ||
READWRITE(nSatoshisPerK); | ||
} | ||
}; | ||
|
||
#endif // BITCOIN_AMOUNT_H | ||
#endif // PIVX_AMOUNT_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 <string> | ||
|
||
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 <typename Stream, typename Operation> | ||
inline void SerializationOp(Stream& s, Operation ser_action) | ||
{ | ||
READWRITE(nSatoshisPerK); | ||
} | ||
}; | ||
|
||
#endif // PIVX_POLICY_FEERATE_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,7 @@ | |
|
||
#include "test/test_pivx.h" | ||
|
||
#include "policy/feerate.h" | ||
#include "txmempool.h" | ||
#include "util.h" | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters