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

Method processBlockTx

src/policy/fees.cpp:583–609  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

581}
582
583bool CBlockPolicyEstimator::processBlockTx(unsigned int nBlockHeight, const CTxMemPoolEntry* entry)
584{
585 AssertLockHeld(m_cs_fee_estimator);
586 if (!_removeTx(entry->GetTx().GetHash(), true)) {
587 // This transaction wasn't being tracked for fee estimation
588 return false;
589 }
590
591 // How many blocks did it take for miners to include this transaction?
592 // blocksToConfirm is 1-based, so a transaction included in the earliest
593 // possible block has confirmation count of 1
594 int blocksToConfirm = nBlockHeight - entry->GetHeight();
595 if (blocksToConfirm <= 0) {
596 // This can't happen because we don't process transactions from a block with a height
597 // lower than our greatest seen height
598 LogPrint(BCLog::ESTIMATEFEE, "Blockpolicy error Transaction had negative blocksToConfirm\n");
599 return false;
600 }
601
602 // Feerates are stored and reported as BTC-per-kb:
603 CFeeRate feeRate(entry->GetFee(), entry->GetTxSize());
604
605 feeStats->Record(blocksToConfirm, (double)feeRate.GetFeePerK());
606 shortStats->Record(blocksToConfirm, (double)feeRate.GetFeePerK());
607 longStats->Record(blocksToConfirm, (double)feeRate.GetFeePerK());
608 return true;
609}
610
611void CBlockPolicyEstimator::processBlock(unsigned int nBlockHeight,
612 std::vector<const CTxMemPoolEntry*>& entries)

Callers

nothing calls this directly

Calls 7

GetTxMethod · 0.80
GetFeeMethod · 0.80
RecordMethod · 0.80
GetFeePerKMethod · 0.80
GetHashMethod · 0.45
GetHeightMethod · 0.45
GetTxSizeMethod · 0.45

Tested by

no test coverage detected