Dash Core  0.12.2.1
P2P Digital Currency
TxConfirmStats Class Reference

#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
 

Detailed Description

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.

Definition at line 79 of file fees.h.

Member Function Documentation

◆ ClearCurrent()

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().

◆ EstimateMedianVal()

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

Parameters
confTargettarget number of confirmations
sufficientTxValrequired average number of transactions per block in a bucket range
minSuccessthe success probability we require
requireGreaterreturn the lowest fee/pri such that all higher values pass minSuccess OR return the highest fee/pri such that all lower values fail minSuccess
nBlockHeightthe current block height

Definition at line 78 of file fees.cpp.

Referenced by CBlockPolicyEstimator::estimateFee(), CBlockPolicyEstimator::estimatePriority(), CBlockPolicyEstimator::estimateSmartFee(), CBlockPolicyEstimator::estimateSmartPriority(), and CBlockPolicyEstimator::processBlock().

◆ GetMaxConfirms()

unsigned int TxConfirmStats::GetMaxConfirms ( )
inline

◆ Initialize()

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.

Parameters
defaultBucketscontains the upper limits for the bucket boundaries
maxConfirmsmax number of confirms to track
decayhow much to decay the historical moving average per block
dataTypeStringfor logging purposes

Definition at line 15 of file fees.cpp.

Referenced by CBlockPolicyEstimator::CBlockPolicyEstimator().

◆ NewTx()

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().

◆ Read()

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().

◆ Record()

void TxConfirmStats::Record ( int  blocksToConfirm,
double  val 
)

Record a new transaction data point in the current block stats

Parameters
blocksToConfirmthe number of blocks it took this transaction to confirm
valeither the fee or the priority when entered of the transaction
Warning
blocksToConfirm is 1-based and has to be >= 1

Definition at line 54 of file fees.cpp.

Referenced by CBlockPolicyEstimator::processBlockTx().

◆ removeTx()

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().

◆ UpdateMovingAverages()

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().

◆ Write()

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().

Member Data Documentation

◆ avg

std::vector<double> TxConfirmStats::avg
private

Definition at line 101 of file fees.h.

Referenced by EstimateMedianVal(), Initialize(), Read(), UpdateMovingAverages(), and Write().

◆ bucketMap

std::map<double, unsigned int> TxConfirmStats::bucketMap
private

Definition at line 84 of file fees.h.

Referenced by Initialize(), NewTx(), Read(), and Record().

◆ buckets

std::vector<double> TxConfirmStats::buckets
private

Definition at line 83 of file fees.h.

Referenced by ClearCurrent(), EstimateMedianVal(), Initialize(), Read(), UpdateMovingAverages(), and Write().

◆ confAvg

std::vector<std::vector<double> > TxConfirmStats::confAvg
private

Definition at line 95 of file fees.h.

Referenced by EstimateMedianVal(), GetMaxConfirms(), Initialize(), Read(), UpdateMovingAverages(), and Write().

◆ curBlockConf

std::vector<std::vector<int> > TxConfirmStats::curBlockConf
private

Definition at line 97 of file fees.h.

Referenced by ClearCurrent(), Initialize(), Read(), Record(), and UpdateMovingAverages().

◆ curBlockTxCt

std::vector<int> TxConfirmStats::curBlockTxCt
private

Definition at line 91 of file fees.h.

Referenced by ClearCurrent(), Initialize(), Read(), Record(), and UpdateMovingAverages().

◆ curBlockVal

std::vector<double> TxConfirmStats::curBlockVal
private

Definition at line 103 of file fees.h.

Referenced by ClearCurrent(), Initialize(), Read(), Record(), and UpdateMovingAverages().

◆ dataTypeString

std::string TxConfirmStats::dataTypeString
private

Definition at line 108 of file fees.h.

Referenced by EstimateMedianVal(), Initialize(), NewTx(), and Read().

◆ decay

double TxConfirmStats::decay
private

Definition at line 109 of file fees.h.

Referenced by EstimateMedianVal(), Initialize(), Read(), UpdateMovingAverages(), and Write().

◆ oldUnconfTxs

std::vector<int> TxConfirmStats::oldUnconfTxs
private

Definition at line 116 of file fees.h.

Referenced by ClearCurrent(), EstimateMedianVal(), Initialize(), Read(), and removeTx().

◆ txCtAvg

std::vector<double> TxConfirmStats::txCtAvg
private

Definition at line 89 of file fees.h.

Referenced by EstimateMedianVal(), Initialize(), Read(), UpdateMovingAverages(), and Write().

◆ unconfTxs

std::vector<std::vector<int> > TxConfirmStats::unconfTxs
private

Definition at line 114 of file fees.h.

Referenced by ClearCurrent(), EstimateMedianVal(), Initialize(), NewTx(), Read(), and removeTx().


The documentation for this class was generated from the following files: