![]() |
Dash Core
0.12.2.1
P2P Digital Currency
|
#include <fees.h>
Public Member Functions | |
void | Initialize (std::vector< double > &defaultBuckets, unsigned int maxConfirms, double decay, std::string dataTypeString) |
void | ClearCurrent (unsigned int nBlockHeight) |
void | Record (int blocksToConfirm, double val) |
unsigned int | NewTx (unsigned int nBlockHeight, double val) |
void | removeTx (unsigned int entryHeight, unsigned int nBestSeenHeight, unsigned int bucketIndex) |
void | UpdateMovingAverages () |
double | EstimateMedianVal (int confTarget, double sufficientTxVal, double minSuccess, bool requireGreater, unsigned int nBlockHeight) |
unsigned int | GetMaxConfirms () |
void | Write (CAutoFile &fileout) |
void | Read (CAutoFile &filein) |
Private Attributes | |
std::vector< double > | buckets |
std::map< double, unsigned int > | bucketMap |
std::vector< double > | txCtAvg |
std::vector< int > | curBlockTxCt |
std::vector< std::vector< double > > | confAvg |
std::vector< std::vector< int > > | curBlockConf |
std::vector< double > | avg |
std::vector< double > | curBlockVal |
std::string | dataTypeString |
double | decay |
std::vector< std::vector< int > > | unconfTxs |
std::vector< int > | oldUnconfTxs |
We will instantiate two instances of this class, one to track transactions that were included in a block due to fee, and one for tx's included due to priority. We will lump transactions into a bucket according to their approximate fee or priority and then track how long it took for those txs to be included in a block
The tracking of unconfirmed (mempool) transactions is completely independent of the historical tracking of transactions that have been confirmed in a block.
void TxConfirmStats::ClearCurrent | ( | unsigned int | nBlockHeight | ) |
Clear the state of the curBlock variables to start counting for the new block
Definition at line 41 of file fees.cpp.
Referenced by CBlockPolicyEstimator::processBlock().
double TxConfirmStats::EstimateMedianVal | ( | int | confTarget, |
double | sufficientTxVal, | ||
double | minSuccess, | ||
bool | requireGreater, | ||
unsigned int | nBlockHeight | ||
) |
Calculate a fee or priority estimate. Find the lowest value bucket (or range of buckets to make sure we have enough data points) whose transactions still have sufficient likelihood of being confirmed within the target number of confirmations
confTarget | target number of confirmations |
sufficientTxVal | required average number of transactions per block in a bucket range |
minSuccess | the success probability we require |
requireGreater | return the lowest fee/pri such that all higher values pass minSuccess OR return the highest fee/pri such that all lower values fail minSuccess |
nBlockHeight | the current block height |
Definition at line 78 of file fees.cpp.
Referenced by CBlockPolicyEstimator::estimateFee(), CBlockPolicyEstimator::estimatePriority(), CBlockPolicyEstimator::estimateSmartFee(), CBlockPolicyEstimator::estimateSmartPriority(), and CBlockPolicyEstimator::processBlock().
|
inline |
Return the max number of confirms we're tracking
Definition at line 166 of file fees.h.
Referenced by CBlockPolicyEstimator::estimateFee(), EstimateMedianVal(), CBlockPolicyEstimator::estimatePriority(), CBlockPolicyEstimator::estimateSmartFee(), and CBlockPolicyEstimator::estimateSmartPriority().
void TxConfirmStats::Initialize | ( | std::vector< double > & | defaultBuckets, |
unsigned int | maxConfirms, | ||
double | decay, | ||
std::string | dataTypeString | ||
) |
Initialize the data structures. This is called by BlockPolicyEstimator's constructor with default values.
defaultBuckets | contains the upper limits for the bucket boundaries |
maxConfirms | max number of confirms to track |
decay | how much to decay the historical moving average per block |
dataTypeString | for logging purposes |
Definition at line 15 of file fees.cpp.
Referenced by CBlockPolicyEstimator::CBlockPolicyEstimator().
unsigned int TxConfirmStats::NewTx | ( | unsigned int | nBlockHeight, |
double | val | ||
) |
Record a new transaction entering the mempool
Definition at line 248 of file fees.cpp.
Referenced by CBlockPolicyEstimator::processTransaction().
void TxConfirmStats::Read | ( | CAutoFile & | filein | ) |
Read saved state of estimation data from a file and replace all internal data structures and variables with this state.
Definition at line 185 of file fees.cpp.
Referenced by CBlockPolicyEstimator::Read().
void TxConfirmStats::Record | ( | int | blocksToConfirm, |
double | val | ||
) |
Record a new transaction data point in the current block stats
blocksToConfirm | the number of blocks it took this transaction to confirm |
val | either the fee or the priority when entered of the transaction |
Definition at line 54 of file fees.cpp.
Referenced by CBlockPolicyEstimator::processBlockTx().
void TxConfirmStats::removeTx | ( | unsigned int | entryHeight, |
unsigned int | nBestSeenHeight, | ||
unsigned int | bucketIndex | ||
) |
Remove a transaction from mempool tracking stats
Definition at line 257 of file fees.cpp.
Referenced by CBlockPolicyEstimator::removeTx().
void TxConfirmStats::UpdateMovingAverages | ( | ) |
Update our estimates by decaying our historical moving average and updating with the data gathered from the current block
Definition at line 67 of file fees.cpp.
Referenced by CBlockPolicyEstimator::processBlock().
void TxConfirmStats::Write | ( | CAutoFile & | fileout | ) |
Write state of estimation data to a file
Definition at line 176 of file fees.cpp.
Referenced by CBlockPolicyEstimator::Write().
|
private |
Definition at line 101 of file fees.h.
Referenced by EstimateMedianVal(), Initialize(), Read(), UpdateMovingAverages(), and Write().
|
private |
|
private |
Definition at line 83 of file fees.h.
Referenced by ClearCurrent(), EstimateMedianVal(), Initialize(), Read(), UpdateMovingAverages(), and Write().
|
private |
Definition at line 95 of file fees.h.
Referenced by EstimateMedianVal(), GetMaxConfirms(), Initialize(), Read(), UpdateMovingAverages(), and Write().
|
private |
Definition at line 97 of file fees.h.
Referenced by ClearCurrent(), Initialize(), Read(), Record(), and UpdateMovingAverages().
|
private |
Definition at line 91 of file fees.h.
Referenced by ClearCurrent(), Initialize(), Read(), Record(), and UpdateMovingAverages().
|
private |
Definition at line 103 of file fees.h.
Referenced by ClearCurrent(), Initialize(), Read(), Record(), and UpdateMovingAverages().
|
private |
Definition at line 108 of file fees.h.
Referenced by EstimateMedianVal(), Initialize(), NewTx(), and Read().
|
private |
Definition at line 109 of file fees.h.
Referenced by EstimateMedianVal(), Initialize(), Read(), UpdateMovingAverages(), and Write().
|
private |
Definition at line 116 of file fees.h.
Referenced by ClearCurrent(), EstimateMedianVal(), Initialize(), Read(), and removeTx().
|
private |
Definition at line 89 of file fees.h.
Referenced by EstimateMedianVal(), Initialize(), Read(), UpdateMovingAverages(), and Write().
|
private |
Definition at line 114 of file fees.h.
Referenced by ClearCurrent(), EstimateMedianVal(), Initialize(), NewTx(), Read(), and removeTx().