|
|
@ -16,10 +16,14 @@ void TxConfirmStats::Initialize(std::vector<double>& defaultBuckets, |
|
|
|
{ |
|
|
|
decay = _decay; |
|
|
|
dataTypeString = _dataTypeString; |
|
|
|
for (unsigned int i = 0; i < defaultBuckets.size(); i++) { |
|
|
|
buckets.push_back(defaultBuckets[i]); |
|
|
|
bucketMap[defaultBuckets[i]] = i; |
|
|
|
|
|
|
|
buckets.insert(buckets.end(), defaultBuckets.begin(), defaultBuckets.end()); |
|
|
|
buckets.push_back(std::numeric_limits<double>::infinity()); |
|
|
|
|
|
|
|
for (unsigned int i = 0; i < buckets.size(); i++) { |
|
|
|
bucketMap[buckets[i]] = i; |
|
|
|
} |
|
|
|
|
|
|
|
confAvg.resize(maxConfirms); |
|
|
|
curBlockConf.resize(maxConfirms); |
|
|
|
unconfTxs.resize(maxConfirms); |
|
|
@ -49,13 +53,19 @@ void TxConfirmStats::ClearCurrent(unsigned int nBlockHeight) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
unsigned int TxConfirmStats::FindBucketIndex(double val) |
|
|
|
{ |
|
|
|
auto it = bucketMap.lower_bound(val); |
|
|
|
assert(it != bucketMap.end()); |
|
|
|
return it->second; |
|
|
|
} |
|
|
|
|
|
|
|
void TxConfirmStats::Record(int blocksToConfirm, double val) |
|
|
|
{ |
|
|
|
// blocksToConfirm is 1-based
|
|
|
|
if (blocksToConfirm < 1) |
|
|
|
return; |
|
|
|
unsigned int bucketindex = bucketMap.lower_bound(val)->second; |
|
|
|
unsigned int bucketindex = FindBucketIndex(val); |
|
|
|
for (size_t i = blocksToConfirm; i <= curBlockConf.size(); i++) { |
|
|
|
curBlockConf[i - 1][bucketindex]++; |
|
|
|
} |
|
|
@ -246,7 +256,7 @@ void TxConfirmStats::Read(CAutoFile& filein) |
|
|
|
|
|
|
|
unsigned int TxConfirmStats::NewTx(unsigned int nBlockHeight, double val) |
|
|
|
{ |
|
|
|
unsigned int bucketindex = bucketMap.lower_bound(val)->second; |
|
|
|
unsigned int bucketindex = FindBucketIndex(val); |
|
|
|
unsigned int blockIndex = nBlockHeight % unconfTxs.size(); |
|
|
|
unconfTxs[blockIndex][bucketindex]++; |
|
|
|
LogPrint("estimatefee", "adding to %s", dataTypeString); |
|
|
@ -306,7 +316,6 @@ CBlockPolicyEstimator::CBlockPolicyEstimator(const CFeeRate& _minRelayFee) |
|
|
|
for (double bucketBoundary = minTrackedFee.GetFeePerK(); bucketBoundary <= MAX_FEERATE; bucketBoundary *= FEE_SPACING) { |
|
|
|
vfeelist.push_back(bucketBoundary); |
|
|
|
} |
|
|
|
vfeelist.push_back(INF_FEERATE); |
|
|
|
feeStats.Initialize(vfeelist, MAX_BLOCK_CONFIRMS, DEFAULT_DECAY, "FeeRate"); |
|
|
|
|
|
|
|
minTrackedPriority = AllowFreeThreshold() < MIN_PRIORITY ? MIN_PRIORITY : AllowFreeThreshold(); |
|
|
@ -314,7 +323,6 @@ CBlockPolicyEstimator::CBlockPolicyEstimator(const CFeeRate& _minRelayFee) |
|
|
|
for (double bucketBoundary = minTrackedPriority; bucketBoundary <= MAX_PRIORITY; bucketBoundary *= PRI_SPACING) { |
|
|
|
vprilist.push_back(bucketBoundary); |
|
|
|
} |
|
|
|
vprilist.push_back(INF_PRIORITY); |
|
|
|
priStats.Initialize(vprilist, MAX_BLOCK_CONFIRMS, DEFAULT_DECAY, "Priority"); |
|
|
|
|
|
|
|
feeUnlikely = CFeeRate(0); |
|
|
|