MCPcopy Create free account
hub / github.com/ElementsProject/elements / CBlockPolicyEstimator

Method CBlockPolicyEstimator

src/policy/fees.cpp:514–538  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

512}
513
514CBlockPolicyEstimator::CBlockPolicyEstimator()
515 : nBestSeenHeight(0), firstRecordedHeight(0), historicalFirst(0), historicalBest(0), trackedTxs(0), untrackedTxs(0)
516{
517 static_assert(MIN_BUCKET_FEERATE > 0, "Min feerate must be nonzero");
518 size_t bucketIndex = 0;
519
520 for (double bucketBoundary = MIN_BUCKET_FEERATE; bucketBoundary <= MAX_BUCKET_FEERATE; bucketBoundary *= FEE_SPACING, bucketIndex++) {
521 buckets.push_back(bucketBoundary);
522 bucketMap[bucketBoundary] = bucketIndex;
523 }
524 buckets.push_back(INF_FEERATE);
525 bucketMap[INF_FEERATE] = bucketIndex;
526 assert(bucketMap.size() == buckets.size());
527
528 feeStats = std::unique_ptr<TxConfirmStats>(new TxConfirmStats(buckets, bucketMap, MED_BLOCK_PERIODS, MED_DECAY, MED_SCALE));
529 shortStats = std::unique_ptr<TxConfirmStats>(new TxConfirmStats(buckets, bucketMap, SHORT_BLOCK_PERIODS, SHORT_DECAY, SHORT_SCALE));
530 longStats = std::unique_ptr<TxConfirmStats>(new TxConfirmStats(buckets, bucketMap, LONG_BLOCK_PERIODS, LONG_DECAY, LONG_SCALE));
531
532 // If the fee estimation file is present, read recorded estimations
533 fs::path est_filepath = gArgs.GetDataDirNet() / FEE_ESTIMATES_FILENAME;
534 CAutoFile est_file(fsbridge::fopen(est_filepath, "rb"), SER_DISK, CLIENT_VERSION);
535 if (est_file.IsNull() || !Read(est_file)) {
536 LogPrintf("Failed to read fee estimates from %s. Continue anyway.\n", fs::PathToString(est_filepath));
537 }
538}
539
540CBlockPolicyEstimator::~CBlockPolicyEstimator()
541{

Callers

nothing calls this directly

Calls 5

fopenFunction · 0.85
PathToStringFunction · 0.85
push_backMethod · 0.45
sizeMethod · 0.45
IsNullMethod · 0.45

Tested by

no test coverage detected