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

Method processTransaction

src/policy/fees.cpp:544–581  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

542}
543
544void CBlockPolicyEstimator::processTransaction(const CTxMemPoolEntry& entry, bool validFeeEstimate)
545{
546 LOCK(m_cs_fee_estimator);
547 unsigned int txHeight = entry.GetHeight();
548 uint256 hash = entry.GetTx().GetHash();
549 if (mapMemPoolTxs.count(hash)) {
550 LogPrint(BCLog::ESTIMATEFEE, "Blockpolicy error mempool tx %s already being tracked\n",
551 hash.ToString());
552 return;
553 }
554
555 if (txHeight != nBestSeenHeight) {
556 // Ignore side chains and re-orgs; assuming they are random they don't
557 // affect the estimate. We'll potentially double count transactions in 1-block reorgs.
558 // Ignore txs if BlockPolicyEstimator is not in sync with ActiveChain().Tip().
559 // It will be synced next time a block is processed.
560 return;
561 }
562
563 // Only want to be updating estimates when our blockchain is synced,
564 // otherwise we'll miscalculate how many blocks its taking to get included.
565 if (!validFeeEstimate) {
566 untrackedTxs++;
567 return;
568 }
569 trackedTxs++;
570
571 // Feerates are stored and reported as BTC-per-kb:
572 CFeeRate feeRate(entry.GetFee(), entry.GetTxSize());
573
574 mapMemPoolTxs[hash].blockHeight = txHeight;
575 unsigned int bucketIndex = feeStats->NewTx(txHeight, (double)feeRate.GetFeePerK());
576 mapMemPoolTxs[hash].bucketIndex = bucketIndex;
577 unsigned int bucketIndex2 = shortStats->NewTx(txHeight, (double)feeRate.GetFeePerK());
578 assert(bucketIndex == bucketIndex2);
579 unsigned int bucketIndex3 = longStats->NewTx(txHeight, (double)feeRate.GetFeePerK());
580 assert(bucketIndex == bucketIndex3);
581}
582
583bool CBlockPolicyEstimator::processBlockTx(unsigned int nBlockHeight, const CTxMemPoolEntry* entry)
584{

Callers 2

addUncheckedMethod · 0.80
FUZZ_TARGET_INITFunction · 0.80

Calls 9

GetTxMethod · 0.80
countMethod · 0.80
GetFeeMethod · 0.80
NewTxMethod · 0.80
GetFeePerKMethod · 0.80
GetHeightMethod · 0.45
GetHashMethod · 0.45
ToStringMethod · 0.45
GetTxSizeMethod · 0.45

Tested by 1

FUZZ_TARGET_INITFunction · 0.64