Skip to content

Commit ebafdca

Browse files
committed
Pass pointers to existing CTxMemPoolEntries to fee estimation
1 parent d825838 commit ebafdca

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

src/policy/fees.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -334,17 +334,17 @@ void CBlockPolicyEstimator::processTransaction(const CTxMemPoolEntry& entry, boo
334334
mapMemPoolTxs[hash].bucketIndex = feeStats.NewTx(txHeight, (double)feeRate.GetFeePerK());
335335
}
336336

337-
void CBlockPolicyEstimator::processBlockTx(unsigned int nBlockHeight, const CTxMemPoolEntry& entry)
337+
void CBlockPolicyEstimator::processBlockTx(unsigned int nBlockHeight, const CTxMemPoolEntry* entry)
338338
{
339-
if (!removeTx(entry.GetTx().GetHash())) {
339+
if (!removeTx(entry->GetTx().GetHash())) {
340340
// This transaction wasn't being tracked for fee estimation
341341
return;
342342
}
343343

344344
// How many blocks did it take for miners to include this transaction?
345345
// blocksToConfirm is 1-based, so a transaction included in the earliest
346346
// possible block has confirmation count of 1
347-
int blocksToConfirm = nBlockHeight - entry.GetHeight();
347+
int blocksToConfirm = nBlockHeight - entry->GetHeight();
348348
if (blocksToConfirm <= 0) {
349349
// This can't happen because we don't process transactions from a block with a height
350350
// lower than our greatest seen height
@@ -353,13 +353,13 @@ void CBlockPolicyEstimator::processBlockTx(unsigned int nBlockHeight, const CTxM
353353
}
354354

355355
// Feerates are stored and reported as BTC-per-kb:
356-
CFeeRate feeRate(entry.GetFee(), entry.GetTxSize());
356+
CFeeRate feeRate(entry->GetFee(), entry->GetTxSize());
357357

358358
feeStats.Record(blocksToConfirm, (double)feeRate.GetFeePerK());
359359
}
360360

361361
void CBlockPolicyEstimator::processBlock(unsigned int nBlockHeight,
362-
std::vector<CTxMemPoolEntry>& entries)
362+
std::vector<const CTxMemPoolEntry*>& entries)
363363
{
364364
if (nBlockHeight <= nBestSeenHeight) {
365365
// Ignore side chains and re-orgs; assuming they are random

src/policy/fees.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -203,10 +203,10 @@ class CBlockPolicyEstimator
203203

204204
/** Process all the transactions that have been included in a block */
205205
void processBlock(unsigned int nBlockHeight,
206-
std::vector<CTxMemPoolEntry>& entries);
206+
std::vector<const CTxMemPoolEntry*>& entries);
207207

208208
/** Process a transaction confirmed in a block*/
209-
void processBlockTx(unsigned int nBlockHeight, const CTxMemPoolEntry& entry);
209+
void processBlockTx(unsigned int nBlockHeight, const CTxMemPoolEntry* entry);
210210

211211
/** Process a transaction accepted to the mempool*/
212212
void processTransaction(const CTxMemPoolEntry& entry, bool validFeeEstimate);

src/txmempool.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -594,14 +594,14 @@ void CTxMemPool::removeConflicts(const CTransaction &tx)
594594
void CTxMemPool::removeForBlock(const std::vector<CTransactionRef>& vtx, unsigned int nBlockHeight)
595595
{
596596
LOCK(cs);
597-
std::vector<CTxMemPoolEntry> entries;
597+
std::vector<const CTxMemPoolEntry*> entries;
598598
for (const auto& tx : vtx)
599599
{
600600
uint256 hash = tx->GetHash();
601601

602602
indexed_transaction_set::iterator i = mapTx.find(hash);
603603
if (i != mapTx.end())
604-
entries.push_back(*i);
604+
entries.push_back(&*i);
605605
}
606606
// Before the txs in the new block have been removed from the mempool, update policy estimates
607607
minerPolicyEstimator->processBlock(nBlockHeight, entries);

0 commit comments

Comments
 (0)