Changeset View
Changeset View
Standalone View
Standalone View
src/policy/fees.h
// Copyright (c) 2009-2010 Satoshi Nakamoto | // Copyright (c) 2009-2010 Satoshi Nakamoto | ||||
// Copyright (c) 2009-2016 The Bitcoin Core developers | // Copyright (c) 2009-2016 The Bitcoin Core developers | ||||
// Distributed under the MIT software license, see the accompanying | // Distributed under the MIT software license, see the accompanying | ||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php. | // file COPYING or http://www.opensource.org/licenses/mit-license.php. | ||||
#ifndef BITCOIN_POLICYESTIMATOR_H | #ifndef BITCOIN_POLICYESTIMATOR_H | ||||
#define BITCOIN_POLICYESTIMATOR_H | #define BITCOIN_POLICYESTIMATOR_H | ||||
#include "amount.h" | #include "amount.h" | ||||
#include "random.h" | #include "random.h" | ||||
#include "uint256.h" | #include "uint256.h" | ||||
#include <map> | #include <map> | ||||
#include <string> | #include <string> | ||||
#include <vector> | #include <vector> | ||||
class CFeeRate; | class CFeeRate; | ||||
class CTxMemPoolEntry; | |||||
class CTxMemPool; | |||||
/** \class MempoolFeeEstimator | |||||
* The MempoolFeeEstimator is used for estimating the feerate needed for a | |||||
* transaction to be included in a block within a certain number of blocks. | |||||
*/ | |||||
class MempoolFeeEstimator { | |||||
private: | |||||
std::vector<CFeeRate> m_minHeap; | |||||
std::vector<CFeeRate> m_maxHeap; | |||||
public: | |||||
MempoolFeeEstimator() {} | |||||
/** | |||||
* Clear the state of the curBlock variables to start counting for after a | |||||
* block is received. | |||||
*/ | |||||
void clear(); | |||||
/** | |||||
* Record a new fee data point in the current block stats | |||||
*/ | |||||
void addFee(CFeeRate fee); | |||||
/** | |||||
* Calculate a feerate estimate. | |||||
*/ | |||||
CFeeRate estimateMedian(); | |||||
}; | |||||
// Minimum and Maximum values for tracking feerates | // Minimum and Maximum values for tracking feerates | ||||
static constexpr Amount MIN_FEERATE(10 * SATOSHI); | static constexpr Amount MIN_FEERATE(10 * SATOSHI); | ||||
static const Amount MAX_FEERATE(int64_t(1e7) * SATOSHI); | static const Amount MAX_FEERATE(int64_t(1e7) * SATOSHI); | ||||
// We have to lump transactions into buckets based on feerate, but we want to be | // We have to lump transactions into buckets based on feerate, but we want to be | ||||
// able to give accurate estimates over a large range of potential feerates. | // able to give accurate estimates over a large range of potential feerates. | ||||
// Therefore it makes sense to exponentially space the buckets | // Therefore it makes sense to exponentially space the buckets | ||||
Show All 16 Lines |