Skip to content

Commit 65aaf94

Browse files
committed
refactor: move update_* structs from txmempool.h to .cpp file
These helpers are exclusively used in txmempool.cpp, hence they should also be moved there. Can be reviewed with "--color-moved=dimmed-zebra".
1 parent 9947ce6 commit 65aaf94

File tree

2 files changed

+52
-52
lines changed

2 files changed

+52
-52
lines changed

src/txmempool.cpp

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,58 @@
2121
#include <cmath>
2222
#include <optional>
2323

24+
// Helpers for modifying CTxMemPool::mapTx, which is a boost multi_index.
25+
struct update_descendant_state
26+
{
27+
update_descendant_state(int64_t _modifySize, CAmount _modifyFee, int64_t _modifyCount) :
28+
modifySize(_modifySize), modifyFee(_modifyFee), modifyCount(_modifyCount)
29+
{}
30+
31+
void operator() (CTxMemPoolEntry &e)
32+
{ e.UpdateDescendantState(modifySize, modifyFee, modifyCount); }
33+
34+
private:
35+
int64_t modifySize;
36+
CAmount modifyFee;
37+
int64_t modifyCount;
38+
};
39+
40+
struct update_ancestor_state
41+
{
42+
update_ancestor_state(int64_t _modifySize, CAmount _modifyFee, int64_t _modifyCount, int64_t _modifySigOpsCost) :
43+
modifySize(_modifySize), modifyFee(_modifyFee), modifyCount(_modifyCount), modifySigOpsCost(_modifySigOpsCost)
44+
{}
45+
46+
void operator() (CTxMemPoolEntry &e)
47+
{ e.UpdateAncestorState(modifySize, modifyFee, modifyCount, modifySigOpsCost); }
48+
49+
private:
50+
int64_t modifySize;
51+
CAmount modifyFee;
52+
int64_t modifyCount;
53+
int64_t modifySigOpsCost;
54+
};
55+
56+
struct update_fee_delta
57+
{
58+
explicit update_fee_delta(int64_t _feeDelta) : feeDelta(_feeDelta) { }
59+
60+
void operator() (CTxMemPoolEntry &e) { e.UpdateFeeDelta(feeDelta); }
61+
62+
private:
63+
int64_t feeDelta;
64+
};
65+
66+
struct update_lock_points
67+
{
68+
explicit update_lock_points(const LockPoints& _lp) : lp(_lp) { }
69+
70+
void operator() (CTxMemPoolEntry &e) { e.UpdateLockPoints(lp); }
71+
72+
private:
73+
const LockPoints& lp;
74+
};
75+
2476
CTxMemPoolEntry::CTxMemPoolEntry(const CTransactionRef& tx, CAmount fee,
2577
int64_t time, unsigned int entry_height,
2678
bool spends_coinbase, int64_t sigops_cost, LockPoints lp)

src/txmempool.h

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

162-
// Helpers for modifying CTxMemPool::mapTx, which is a boost multi_index.
163-
struct update_descendant_state
164-
{
165-
update_descendant_state(int64_t _modifySize, CAmount _modifyFee, int64_t _modifyCount) :
166-
modifySize(_modifySize), modifyFee(_modifyFee), modifyCount(_modifyCount)
167-
{}
168-
169-
void operator() (CTxMemPoolEntry &e)
170-
{ e.UpdateDescendantState(modifySize, modifyFee, modifyCount); }
171-
172-
private:
173-
int64_t modifySize;
174-
CAmount modifyFee;
175-
int64_t modifyCount;
176-
};
177-
178-
struct update_ancestor_state
179-
{
180-
update_ancestor_state(int64_t _modifySize, CAmount _modifyFee, int64_t _modifyCount, int64_t _modifySigOpsCost) :
181-
modifySize(_modifySize), modifyFee(_modifyFee), modifyCount(_modifyCount), modifySigOpsCost(_modifySigOpsCost)
182-
{}
183-
184-
void operator() (CTxMemPoolEntry &e)
185-
{ e.UpdateAncestorState(modifySize, modifyFee, modifyCount, modifySigOpsCost); }
186-
187-
private:
188-
int64_t modifySize;
189-
CAmount modifyFee;
190-
int64_t modifyCount;
191-
int64_t modifySigOpsCost;
192-
};
193-
194-
struct update_fee_delta
195-
{
196-
explicit update_fee_delta(int64_t _feeDelta) : feeDelta(_feeDelta) { }
197-
198-
void operator() (CTxMemPoolEntry &e) { e.UpdateFeeDelta(feeDelta); }
199-
200-
private:
201-
int64_t feeDelta;
202-
};
203-
204-
struct update_lock_points
205-
{
206-
explicit update_lock_points(const LockPoints& _lp) : lp(_lp) { }
207-
208-
void operator() (CTxMemPoolEntry &e) { e.UpdateLockPoints(lp); }
209-
210-
private:
211-
const LockPoints& lp;
212-
};
213-
214162
// extracts a transaction hash from CTxMemPoolEntry or CTransactionRef
215163
struct mempoolentry_txid
216164
{

0 commit comments

Comments
 (0)