6 #ifndef PIVX_POLICY_FEES_H
7 #define PIVX_POLICY_FEES_H
87 std::vector<std::vector<double> >
confAvg;
93 std::vector<double>
avg;
117 void Initialize(std::vector<double>& defaultBuckets,
unsigned int maxConfirms,
double decay);
128 void Record(
int blocksToConfirm,
double val);
131 unsigned int NewTx(
unsigned int nBlockHeight,
double val);
134 void removeTx(
unsigned int entryHeight,
unsigned int nBestSeenHeight,
135 unsigned int bucketIndex);
153 double minSuccess,
bool requireGreater,
unsigned int nBlockHeight);
171 static const unsigned int MAX_BLOCK_CONFIRMS = 25;
174 static const double DEFAULT_DECAY = .998;
177 static const double MIN_SUCCESS_PCT = .95;
178 static const double UNLIKELY_PCT = .5;
181 static const double SUFFICIENT_FEETXS = 1;
184 static constexpr
double MIN_FEERATE = 10;
185 static const double MAX_FEERATE = 1e7;
186 static const double INF_FEERATE = 1e16;
192 static const double FEE_SPACING = 1.1;
208 std::vector<const CTxMemPoolEntry*>& entries);
Non-refcounted RAII wrapper for FILE*.
We want to be able to estimate feerates or priorities that are needed on tx's to be included in a cer...
unsigned int untrackedTxs
unsigned int nBestSeenHeight
Passed to constructor to avoid dependency on main.
TxConfirmStats feeStats
Classes to track historical data on transaction confirmations.
bool removeTx(const uint256 &hash)
Remove a transaction from the mempool tracking stats.
void Write(CAutoFile &fileout)
Write estimation data to a file.
CFeeRate estimateFee(int confTarget)
Return a feerate estimate.
CBlockPolicyEstimator(const CFeeRate &minRelayFee)
Create new BlockPolicyEstimator and initialize stats tracking classes with default values.
void Read(CAutoFile &filein, int nFileVersion)
Read estimation data from a file.
CFeeRate estimateSmartFee(int confTarget, int *answerFoundAtTarget, const CTxMemPool &pool)
Estimate feerate needed to get be included in a block within confTarget blocks.
bool processBlockTx(unsigned int nBlockHeight, const CTxMemPoolEntry *entry)
Process a transaction confirmed in a block.
std::map< uint256, TxStatsInfo > mapMemPoolTxs
void processTransaction(const CTxMemPoolEntry &entry, bool validFeeEstimate)
Process a transaction accepted to the mempool.
void processBlock(unsigned int nBlockHeight, std::vector< const CTxMemPoolEntry * > &entries)
Process all the transactions that have been included in a block.
Fee rate in PIV per kilobyte: CAmount / kB.
CTxMemPoolEntry stores data about the corresponding transaction, as well as data about all in-mempool...
CTxMemPool stores valid-according-to-the-current-best-chain transactions that may be included in the ...
We will instantiate an instance of this class to track transactions that were included in a block.
std::vector< double > buckets
std::vector< double > curBlockVal
std::map< double, unsigned int > bucketMap
void Read(CAutoFile &filein)
Read saved state of estimation data from a file and replace all internal data structures and variable...
void ClearCurrent(unsigned int nBlockHeight)
Clear the state of the curBlock variables to start counting for the new block.
void removeTx(unsigned int entryHeight, unsigned int nBestSeenHeight, unsigned int bucketIndex)
Remove a transaction from mempool tracking stats.
void Write(CAutoFile &fileout)
Write state of estimation data to a file.
void Record(int blocksToConfirm, double val)
Record a new transaction data point in the current block stats.
std::vector< double > txCtAvg
double EstimateMedianVal(int confTarget, double sufficientTxVal, double minSuccess, bool requireGreater, unsigned int nBlockHeight)
Calculate a feerate estimate.
std::vector< int > oldUnconfTxs
std::vector< int > curBlockTxCt
std::vector< std::vector< int > > curBlockConf
void UpdateMovingAverages()
Update our estimates by decaying our historical moving average and updating with the data gathered fr...
void Initialize(std::vector< double > &defaultBuckets, unsigned int maxConfirms, double decay)
Initialize the data structures.
std::vector< double > avg
std::vector< std::vector< double > > confAvg
unsigned int GetMaxConfirms()
Return the max number of confirms we're tracking.
std::vector< std::vector< int > > unconfTxs
unsigned int NewTx(unsigned int nBlockHeight, double val)
Record a new transaction entering the mempool.