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

Method processBlock

src/policy/fees.cpp:611–658  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers 2

removeForBlockMethod · 0.80
FUZZ_TARGET_INITFunction · 0.80

Calls 3

ClearCurrentMethod · 0.80
UpdateMovingAveragesMethod · 0.80
sizeMethod · 0.45

Tested by 1

FUZZ_TARGET_INITFunction · 0.64