Skip to content

Commit 0a14a16

Browse files
committed
Merge bitcoin/bitcoin#24625: Replace struct update_fee_delta with lambda
fa84a49 Use CAmount for fee delta and modified fee (MarcoFalke) fa8857c Replace struct update_fee_delta with lambda (MarcoFalke) Pull request description: The same was done for another struct in e177fca. Also, change type of feeDelta from int64_t to CAmount. ACKs for top commit: hebasto: re-ACK fa84a49 promag: Code review ACK fa84a49. Tree-SHA512: 2b9ee449d348b0f685793a35c6dd3c57ed97fdf707a89495a0518bb332f407303b48723e667351e96f2b698e0a2ade27095517a3accd926d4ec85e58d6fd441f
2 parents 4a0ab35 + fa84a49 commit 0a14a16

File tree

3 files changed

+8
-18
lines changed

3 files changed

+8
-18
lines changed

src/node/miner.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ struct CTxMemPoolModifiedEntry {
4545
nSigOpCostWithAncestors = entry->GetSigOpCostWithAncestors();
4646
}
4747

48-
int64_t GetModifiedFee() const { return iter->GetModifiedFee(); }
48+
CAmount GetModifiedFee() const { return iter->GetModifiedFee(); }
4949
uint64_t GetSizeWithAncestors() const { return nSizeWithAncestors; }
5050
CAmount GetModFeesWithAncestors() const { return nModFeesWithAncestors; }
5151
size_t GetTxSize() const { return iter->GetTxSize(); }

src/txmempool.cpp

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -54,16 +54,6 @@ struct update_ancestor_state
5454
int64_t modifySigOpsCost;
5555
};
5656

57-
struct update_fee_delta
58-
{
59-
explicit update_fee_delta(int64_t _feeDelta) : feeDelta(_feeDelta) { }
60-
61-
void operator() (CTxMemPoolEntry &e) { e.UpdateFeeDelta(feeDelta); }
62-
63-
private:
64-
int64_t feeDelta;
65-
};
66-
6757
bool TestLockPointValidity(CChain& active_chain, const LockPoints& lp)
6858
{
6959
AssertLockHeld(cs_main);
@@ -99,7 +89,7 @@ CTxMemPoolEntry::CTxMemPoolEntry(const CTransactionRef& tx, CAmount fee,
9989
nModFeesWithAncestors{nFee},
10090
nSigOpCostWithAncestors{sigOpCost} {}
10191

102-
void CTxMemPoolEntry::UpdateFeeDelta(int64_t newFeeDelta)
92+
void CTxMemPoolEntry::UpdateFeeDelta(CAmount newFeeDelta)
10393
{
10494
nModFeesWithDescendants += newFeeDelta - feeDelta;
10595
nModFeesWithAncestors += newFeeDelta - feeDelta;
@@ -496,7 +486,7 @@ void CTxMemPool::addUnchecked(const CTxMemPoolEntry &entry, setEntries &setAnces
496486
CAmount delta{0};
497487
ApplyDelta(entry.GetTx().GetHash(), delta);
498488
if (delta) {
499-
mapTx.modify(newit, update_fee_delta(delta));
489+
mapTx.modify(newit, [&delta](CTxMemPoolEntry& e) { e.UpdateFeeDelta(delta); });
500490
}
501491

502492
// Update cachedInnerUsage to include contained transaction's usage.
@@ -931,7 +921,7 @@ void CTxMemPool::PrioritiseTransaction(const uint256& hash, const CAmount& nFeeD
931921
delta += nFeeDelta;
932922
txiter it = mapTx.find(hash);
933923
if (it != mapTx.end()) {
934-
mapTx.modify(it, update_fee_delta(delta));
924+
mapTx.modify(it, [&delta](CTxMemPoolEntry& e) { e.UpdateFeeDelta(delta); });
935925
// Now update all ancestors' modified fees with descendants
936926
setEntries setAncestors;
937927
uint64_t nNoLimit = std::numeric_limits<uint64_t>::max();

src/txmempool.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ class CTxMemPoolEntry
101101
const unsigned int entryHeight; //!< Chain height when entering the mempool
102102
const bool spendsCoinbase; //!< keep track of transactions that spend a coinbase
103103
const int64_t sigOpCost; //!< Total sigop cost
104-
int64_t feeDelta{0}; //!< Used for determining the priority of the transaction for mining in a block
104+
CAmount feeDelta{0}; //!< Used for determining the priority of the transaction for mining in a block
105105
LockPoints lockPoints; //!< Track the height and time at which tx was final
106106

107107
// Information about descendants of this transaction that are in the
@@ -131,7 +131,7 @@ class CTxMemPoolEntry
131131
std::chrono::seconds GetTime() const { return std::chrono::seconds{nTime}; }
132132
unsigned int GetHeight() const { return entryHeight; }
133133
int64_t GetSigOpCost() const { return sigOpCost; }
134-
int64_t GetModifiedFee() const { return nFee + feeDelta; }
134+
CAmount GetModifiedFee() const { return nFee + feeDelta; }
135135
size_t DynamicMemoryUsage() const { return nUsageSize; }
136136
const LockPoints& GetLockPoints() const { return lockPoints; }
137137

@@ -140,8 +140,8 @@ class CTxMemPoolEntry
140140
// Adjusts the ancestor state
141141
void UpdateAncestorState(int64_t modifySize, CAmount modifyFee, int64_t modifyCount, int64_t modifySigOps);
142142
// Updates the fee delta used for mining priority score, and the
143-
// modified fees with descendants.
144-
void UpdateFeeDelta(int64_t feeDelta);
143+
// modified fees with descendants/ancestors.
144+
void UpdateFeeDelta(CAmount newFeeDelta);
145145
// Update the LockPoints after a reorg
146146
void UpdateLockPoints(const LockPoints& lp);
147147

0 commit comments

Comments
 (0)