MCPcopy Create free account
hub / github.com/BTCGPU/BTCGPU / processBlock

Method processBlock

src/policy/fees.cpp:615–662  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

613}
614
615void CBlockPolicyEstimator::processBlock(unsigned int nBlockHeight,
616 std::vector<const CTxMemPoolEntry*>& entries)
617{
618 LOCK(cs_feeEstimator);
619 if (nBlockHeight <= nBestSeenHeight) {
620 // Ignore side chains and re-orgs; assuming they are random
621 // they don't affect the estimate.
622 // And if an attacker can re-org the chain at will, then
623 // you've got much bigger problems than "attacker can influence
624 // transaction fees."
625 return;
626 }
627
628 // Must update nBestSeenHeight in sync with ClearCurrent so that
629 // calls to removeTx (via processBlockTx) correctly calculate age
630 // of unconfirmed txs to remove from tracking.
631 nBestSeenHeight = nBlockHeight;
632
633 // Update unconfirmed circular buffer
634 feeStats->ClearCurrent(nBlockHeight);
635 shortStats->ClearCurrent(nBlockHeight);
636 longStats->ClearCurrent(nBlockHeight);
637
638 // Decay all exponential averages
639 feeStats->UpdateMovingAverages();
640 shortStats->UpdateMovingAverages();
641 longStats->UpdateMovingAverages();
642
643 unsigned int countedTxs = 0;
644 // Update averages with data points from current block
645 for (const auto& entry : entries) {
646 if (processBlockTx(nBlockHeight, entry))
647 countedTxs++;
648 }
649
650 if (firstRecordedHeight == 0 && countedTxs > 0) {
651 firstRecordedHeight = nBestSeenHeight;
652 LogPrint(BCLog::ESTIMATEFEE, "Blockpolicy first recorded height %u\n", firstRecordedHeight);
653 }
654
655
656 LogPrint(BCLog::ESTIMATEFEE, "Blockpolicy estimates updated by %u of %u block txs, since last block %u of %u tracked, mempool map size %u, max target %u from %s\n",
657 countedTxs, entries.size(), trackedTxs, trackedTxs + untrackedTxs, mapMemPoolTxs.size(),
658 MaxUsableEstimate(), HistoricalBlockSpan() > BlockSpan() ? "historical" : "current");
659
660 trackedTxs = 0;
661 untrackedTxs = 0;
662}
663
664CFeeRate CBlockPolicyEstimator::estimateFee(int confTarget) const
665{

Callers 1

removeForBlockMethod · 0.80

Calls 3

ClearCurrentMethod · 0.80
UpdateMovingAveragesMethod · 0.80
sizeMethod · 0.45

Tested by

no test coverage detected