PIVX Core  5.6.99
P2P Digital Currency
Public Member Functions | Private Attributes | List of all members
TxConfirmStats Class Reference

We will instantiate an instance of this class to track transactions that were included in a block. More...

#include <fees.h>

Public Member Functions

void Initialize (std::vector< double > &defaultBuckets, unsigned int maxConfirms, double decay)
 Initialize the data structures. More...
 
void ClearCurrent (unsigned int nBlockHeight)
 Clear the state of the curBlock variables to start counting for the new block. More...
 
void Record (int blocksToConfirm, double val)
 Record a new transaction data point in the current block stats. More...
 
unsigned int NewTx (unsigned int nBlockHeight, double val)
 Record a new transaction entering the mempool. More...
 
void removeTx (unsigned int entryHeight, unsigned int nBestSeenHeight, unsigned int bucketIndex)
 Remove a transaction from mempool tracking stats. More...
 
void UpdateMovingAverages ()
 Update our estimates by decaying our historical moving average and updating with the data gathered from the current block. More...
 
double EstimateMedianVal (int confTarget, double sufficientTxVal, double minSuccess, bool requireGreater, unsigned int nBlockHeight)
 Calculate a feerate estimate. More...
 
unsigned int GetMaxConfirms ()
 Return the max number of confirms we're tracking. More...
 
void Write (CAutoFile &fileout)
 Write state of estimation data to a file. More...
 
void Read (CAutoFile &filein)
 Read saved state of estimation data from a file and replace all internal data structures and variables with this state. More...
 

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
 
double decay {0.0}
 
std::vector< std::vector< int > > unconfTxs
 
std::vector< int > oldUnconfTxs
 

Detailed Description

We will instantiate an instance of this class to track transactions that were included in a block.

We will lump transactions into a bucket according to their approximate feerate 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 71 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 39 of file fees.cpp.

Here is the caller graph for this function:

◆ EstimateMedianVal()

double TxConfirmStats::EstimateMedianVal ( int  confTarget,
double  sufficientTxVal,
double  minSuccess,
bool  requireGreater,
unsigned int  nBlockHeight 
)

Calculate a feerate 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 feerate such that all higher values pass minSuccess OR return the highest feerate such that all lower values fail minSuccess
nBlockHeightthe current block height

Definition at line 76 of file fees.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetMaxConfirms()

unsigned int TxConfirmStats::GetMaxConfirms ( )
inline

Return the max number of confirms we're tracking.

Definition at line 156 of file fees.h.

Here is the caller graph for this function:

◆ Initialize()

void TxConfirmStats::Initialize ( std::vector< double > &  defaultBuckets,
unsigned int  maxConfirms,
double  decay 
)

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

Definition at line 14 of file fees.cpp.

◆ NewTx()

unsigned int TxConfirmStats::NewTx ( unsigned int  nBlockHeight,
double  val 
)

Record a new transaction entering the mempool.

Definition at line 246 of file fees.cpp.

Here is the caller graph for this function:

◆ 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 183 of file fees.cpp.

Here is the caller graph for this function:

◆ 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
valthe feerate of the transaction
Warning
blocksToConfirm is 1-based and has to be >= 1

Definition at line 52 of file fees.cpp.

Here is the caller graph for this function:

◆ removeTx()

void TxConfirmStats::removeTx ( unsigned int  entryHeight,
unsigned int  nBestSeenHeight,
unsigned int  bucketIndex 
)

Remove a transaction from mempool tracking stats.

Definition at line 254 of file fees.cpp.

Here is the caller graph for this function:

◆ 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 65 of file fees.cpp.

Here is the caller graph for this function:

◆ Write()

void TxConfirmStats::Write ( CAutoFile fileout)

Write state of estimation data to a file.

Definition at line 174 of file fees.cpp.

Here is the caller graph for this function:

Member Data Documentation

◆ avg

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

Definition at line 93 of file fees.h.

◆ bucketMap

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

Definition at line 76 of file fees.h.

◆ buckets

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

Definition at line 75 of file fees.h.

◆ confAvg

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

Definition at line 87 of file fees.h.

◆ curBlockConf

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

Definition at line 89 of file fees.h.

◆ curBlockTxCt

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

Definition at line 83 of file fees.h.

◆ curBlockVal

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

Definition at line 95 of file fees.h.

◆ decay

double TxConfirmStats::decay {0.0}
private

Definition at line 100 of file fees.h.

◆ oldUnconfTxs

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

Definition at line 107 of file fees.h.

◆ txCtAvg

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

Definition at line 81 of file fees.h.

◆ unconfTxs

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

Definition at line 105 of file fees.h.


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