Skip to content

Commit ee49383

Browse files
committed
merge bitcoin#23211: move update_* structs from txmempool.h to .cpp file
1 parent 3d769c7 commit ee49383

File tree

2 files changed

+53
-53
lines changed

2 files changed

+53
-53
lines changed

src/txmempool.cpp

Lines changed: 53 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,58 @@
3030
#include <cmath>
3131
#include <optional>
3232

33+
// Helpers for modifying CTxMemPool::mapTx, which is a boost multi_index.
34+
struct update_descendant_state
35+
{
36+
update_descendant_state(int64_t _modifySize, CAmount _modifyFee, int64_t _modifyCount) :
37+
modifySize(_modifySize), modifyFee(_modifyFee), modifyCount(_modifyCount)
38+
{}
39+
40+
void operator() (CTxMemPoolEntry &e)
41+
{ e.UpdateDescendantState(modifySize, modifyFee, modifyCount); }
42+
43+
private:
44+
int64_t modifySize;
45+
CAmount modifyFee;
46+
int64_t modifyCount;
47+
};
48+
49+
struct update_ancestor_state
50+
{
51+
update_ancestor_state(int64_t _modifySize, CAmount _modifyFee, int64_t _modifyCount, int64_t _modifySigOpsCost) :
52+
modifySize(_modifySize), modifyFee(_modifyFee), modifyCount(_modifyCount), modifySigOpsCost(_modifySigOpsCost)
53+
{}
54+
55+
void operator() (CTxMemPoolEntry &e)
56+
{ e.UpdateAncestorState(modifySize, modifyFee, modifyCount, modifySigOpsCost); }
57+
58+
private:
59+
int64_t modifySize;
60+
CAmount modifyFee;
61+
int64_t modifyCount;
62+
int64_t modifySigOpsCost;
63+
};
64+
65+
struct update_fee_delta
66+
{
67+
explicit update_fee_delta(int64_t _feeDelta) : feeDelta(_feeDelta) { }
68+
69+
void operator() (CTxMemPoolEntry &e) { e.UpdateFeeDelta(feeDelta); }
70+
71+
private:
72+
int64_t feeDelta;
73+
};
74+
75+
struct update_lock_points
76+
{
77+
explicit update_lock_points(const LockPoints& _lp) : lp(_lp) { }
78+
79+
void operator() (CTxMemPoolEntry &e) { e.UpdateLockPoints(lp); }
80+
81+
private:
82+
const LockPoints& lp;
83+
};
84+
3385
CTxMemPoolEntry::CTxMemPoolEntry(const CTransactionRef& tx, CAmount fee,
3486
int64_t time, unsigned int entry_height,
3587
bool spends_coinbase, int64_t sigops_count, LockPoints lp)
@@ -285,7 +337,7 @@ bool CTxMemPool::CalculateMemPoolAncestors(const CTxMemPoolEntry &entry,
285337

286338
void CTxMemPool::UpdateAncestorsOf(bool add, txiter it, setEntries &setAncestors)
287339
{
288-
CTxMemPoolEntry::Parents parents = it->GetMemPoolParents();
340+
const CTxMemPoolEntry::Parents& parents = it->GetMemPoolParentsConst();
289341
// add or remove this tx as a child of each parent
290342
for (const CTxMemPoolEntry& parent : parents) {
291343
UpdateChild(mapTx.iterator_to(parent), it, add);

src/txmempool.h

Lines changed: 0 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -171,58 +171,6 @@ class CTxMemPoolEntry
171171
mutable Epoch::Marker m_epoch_marker; //!< epoch when last touched, useful for graph algorithms
172172
};
173173

174-
// Helpers for modifying CTxMemPool::mapTx, which is a boost multi_index.
175-
struct update_descendant_state
176-
{
177-
update_descendant_state(int64_t _modifySize, CAmount _modifyFee, int64_t _modifyCount) :
178-
modifySize(_modifySize), modifyFee(_modifyFee), modifyCount(_modifyCount)
179-
{}
180-
181-
void operator() (CTxMemPoolEntry &e)
182-
{ e.UpdateDescendantState(modifySize, modifyFee, modifyCount); }
183-
184-
private:
185-
int64_t modifySize;
186-
CAmount modifyFee;
187-
int64_t modifyCount;
188-
};
189-
190-
struct update_ancestor_state
191-
{
192-
update_ancestor_state(int64_t _modifySize, CAmount _modifyFee, int64_t _modifyCount, int _modifySigOps) :
193-
modifySize(_modifySize), modifyFee(_modifyFee), modifyCount(_modifyCount), modifySigOps(_modifySigOps)
194-
{}
195-
196-
void operator() (CTxMemPoolEntry &e)
197-
{ e.UpdateAncestorState(modifySize, modifyFee, modifyCount, modifySigOps); }
198-
199-
private:
200-
int64_t modifySize;
201-
CAmount modifyFee;
202-
int64_t modifyCount;
203-
int modifySigOps;
204-
};
205-
206-
struct update_fee_delta
207-
{
208-
explicit update_fee_delta(int64_t _feeDelta) : feeDelta(_feeDelta) { }
209-
210-
void operator() (CTxMemPoolEntry &e) { e.UpdateFeeDelta(feeDelta); }
211-
212-
private:
213-
int64_t feeDelta;
214-
};
215-
216-
struct update_lock_points
217-
{
218-
explicit update_lock_points(const LockPoints& _lp) : lp(_lp) { }
219-
220-
void operator() (CTxMemPoolEntry &e) { e.UpdateLockPoints(lp); }
221-
222-
private:
223-
const LockPoints& lp;
224-
};
225-
226174
// extracts a transaction hash from CTxMemPoolEntry or CTransactionRef
227175
struct mempoolentry_txid
228176
{

0 commit comments

Comments
 (0)