Skip to content

Commit c24851b

Browse files
committed
Make MiniMinerMempoolEntry fields private
Follow-up from #27021: accessing of fields in MiniMinerMempoolEntry was done inconsistently. Even though we had a getter, we would directly write to the fields when we needed to update them. This commits sets the fields to private and introduces a method for updating the ancestor information in transactions using the same method name as used for Mempool Entries.
1 parent ac6030e commit c24851b

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

src/node/mini_miner.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -169,9 +169,8 @@ void MiniMiner::DeleteAncestorPackage(const std::set<MockEntryMap::iterator, Ite
169169
for (auto& descendant : it->second) {
170170
// If these fail, we must be double-deducting.
171171
Assume(descendant->second.GetModFeesWithAncestors() >= anc->second.GetModifiedFee());
172-
Assume(descendant->second.vsize_with_ancestors >= anc->second.GetTxSize());
173-
descendant->second.fee_with_ancestors -= anc->second.GetModifiedFee();
174-
descendant->second.vsize_with_ancestors -= anc->second.GetTxSize();
172+
Assume(descendant->second.GetSizeWithAncestors() >= anc->second.GetTxSize());
173+
descendant->second.UpdateAncestorState(-anc->second.GetTxSize(), -anc->second.GetModifiedFee());
175174
}
176175
}
177176
// Delete these entries.

src/node/mini_miner.h

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,13 @@ class MiniMinerMempoolEntry
1919
const CAmount fee_individual;
2020
const CTransactionRef tx;
2121
const int64_t vsize_individual;
22+
CAmount fee_with_ancestors;
23+
int64_t vsize_with_ancestors;
2224

2325
// This class must be constructed while holding mempool.cs. After construction, the object's
2426
// methods can be called without holding that lock.
27+
2528
public:
26-
CAmount fee_with_ancestors;
27-
int64_t vsize_with_ancestors;
2829
explicit MiniMinerMempoolEntry(CTxMemPool::txiter entry) :
2930
fee_individual{entry->GetModifiedFee()},
3031
tx{entry->GetSharedTx()},
@@ -38,6 +39,10 @@ class MiniMinerMempoolEntry
3839
int64_t GetTxSize() const { return vsize_individual; }
3940
int64_t GetSizeWithAncestors() const { return vsize_with_ancestors; }
4041
const CTransaction& GetTx() const LIFETIMEBOUND { return *tx; }
42+
void UpdateAncestorState(int64_t vsize_change, CAmount fee_change) {
43+
vsize_with_ancestors += vsize_change;
44+
fee_with_ancestors += fee_change;
45+
}
4146
};
4247

4348
// Comparator needed for std::set<MockEntryMap::iterator>

0 commit comments

Comments
 (0)