24
24
#include < cmath>
25
25
#include < optional>
26
26
27
- // Helpers for modifying CTxMemPool::mapTx, which is a boost multi_index.
28
- struct update_descendant_state
29
- {
30
- update_descendant_state (int64_t _modifySize, CAmount _modifyFee, int64_t _modifyCount) :
31
- modifySize (_modifySize), modifyFee(_modifyFee), modifyCount(_modifyCount)
32
- {}
33
-
34
- void operator () (CTxMemPoolEntry &e)
35
- { e.UpdateDescendantState (modifySize, modifyFee, modifyCount); }
36
-
37
- private:
38
- int64_t modifySize;
39
- CAmount modifyFee;
40
- int64_t modifyCount;
41
- };
42
-
43
- struct update_ancestor_state
44
- {
45
- update_ancestor_state (int64_t _modifySize, CAmount _modifyFee, int64_t _modifyCount, int64_t _modifySigOpsCost) :
46
- modifySize (_modifySize), modifyFee(_modifyFee), modifyCount(_modifyCount), modifySigOpsCost(_modifySigOpsCost)
47
- {}
48
-
49
- void operator () (CTxMemPoolEntry &e)
50
- { e.UpdateAncestorState (modifySize, modifyFee, modifyCount, modifySigOpsCost); }
51
-
52
- private:
53
- int64_t modifySize;
54
- CAmount modifyFee;
55
- int64_t modifyCount;
56
- int64_t modifySigOpsCost;
57
- };
58
-
59
27
bool TestLockPointValidity (CChain& active_chain, const LockPoints& lp)
60
28
{
61
29
AssertLockHeld (cs_main);
@@ -146,7 +114,9 @@ void CTxMemPool::UpdateForDescendants(txiter updateIt, cacheMap& cachedDescendan
146
114
modifyCount++;
147
115
cachedDescendants[updateIt].insert (mapTx.iterator_to (descendant));
148
116
// Update ancestor state for each descendant
149
- mapTx.modify (mapTx.iterator_to (descendant), update_ancestor_state (updateIt->GetTxSize (), updateIt->GetModifiedFee (), 1 , updateIt->GetSigOpCost ()));
117
+ mapTx.modify (mapTx.iterator_to (descendant), [=](CTxMemPoolEntry& e) {
118
+ e.UpdateAncestorState (updateIt->GetTxSize (), updateIt->GetModifiedFee (), 1 , updateIt->GetSigOpCost ());
119
+ });
150
120
// Don't directly remove the transaction here -- doing so would
151
121
// invalidate iterators in cachedDescendants. Mark it for removal
152
122
// by inserting into descendants_to_remove.
@@ -155,7 +125,7 @@ void CTxMemPool::UpdateForDescendants(txiter updateIt, cacheMap& cachedDescendan
155
125
}
156
126
}
157
127
}
158
- mapTx.modify (updateIt, update_descendant_state ( modifySize, modifyFee, modifyCount));
128
+ mapTx.modify (updateIt, [=](CTxMemPoolEntry& e) { e. UpdateDescendantState ( modifySize, modifyFee, modifyCount); } );
159
129
}
160
130
161
131
void CTxMemPool::UpdateTransactionsFromBlock (const std::vector<uint256>& vHashesToUpdate)
@@ -347,7 +317,7 @@ void CTxMemPool::UpdateAncestorsOf(bool add, txiter it, setEntries &setAncestors
347
317
const int64_t updateSize = updateCount * it->GetTxSize ();
348
318
const CAmount updateFee = updateCount * it->GetModifiedFee ();
349
319
for (txiter ancestorIt : setAncestors) {
350
- mapTx.modify (ancestorIt, update_descendant_state ( updateSize, updateFee, updateCount));
320
+ mapTx.modify (ancestorIt, [=](CTxMemPoolEntry& e) { e. UpdateDescendantState ( updateSize, updateFee, updateCount); } );
351
321
}
352
322
}
353
323
@@ -362,7 +332,7 @@ void CTxMemPool::UpdateEntryForAncestors(txiter it, const setEntries &setAncesto
362
332
updateFee += ancestorIt->GetModifiedFee ();
363
333
updateSigOpsCost += ancestorIt->GetSigOpCost ();
364
334
}
365
- mapTx.modify (it, update_ancestor_state ( updateSize, updateFee, updateCount, updateSigOpsCost));
335
+ mapTx.modify (it, [=](CTxMemPoolEntry& e){ e. UpdateAncestorState ( updateSize, updateFee, updateCount, updateSigOpsCost); } );
366
336
}
367
337
368
338
void CTxMemPool::UpdateChildrenForRemoval (txiter it)
@@ -393,7 +363,7 @@ void CTxMemPool::UpdateForRemoveFromMempool(const setEntries &entriesToRemove, b
393
363
CAmount modifyFee = -removeIt->GetModifiedFee ();
394
364
int modifySigOps = -removeIt->GetSigOpCost ();
395
365
for (txiter dit : setDescendants) {
396
- mapTx.modify (dit, update_ancestor_state ( modifySize, modifyFee, -1 , modifySigOps));
366
+ mapTx.modify (dit, [=](CTxMemPoolEntry& e){ e. UpdateAncestorState ( modifySize, modifyFee, -1 , modifySigOps); } );
397
367
}
398
368
}
399
369
}
@@ -942,14 +912,14 @@ void CTxMemPool::PrioritiseTransaction(const uint256& hash, const CAmount& nFeeD
942
912
std::string dummy;
943
913
CalculateMemPoolAncestors (*it, setAncestors, nNoLimit, nNoLimit, nNoLimit, nNoLimit, dummy, false );
944
914
for (txiter ancestorIt : setAncestors) {
945
- mapTx.modify (ancestorIt, update_descendant_state ( 0 , nFeeDelta, 0 ));
915
+ mapTx.modify (ancestorIt, [=](CTxMemPoolEntry& e){ e. UpdateDescendantState ( 0 , nFeeDelta, 0 );} );
946
916
}
947
917
// Now update all descendants' modified fees with ancestors
948
918
setEntries setDescendants;
949
919
CalculateDescendants (it, setDescendants);
950
920
setDescendants.erase (it);
951
921
for (txiter descendantIt : setDescendants) {
952
- mapTx.modify (descendantIt, update_ancestor_state ( 0 , nFeeDelta, 0 , 0 ));
922
+ mapTx.modify (descendantIt, [=](CTxMemPoolEntry& e){ e. UpdateAncestorState ( 0 , nFeeDelta, 0 , 0 ); } );
953
923
}
954
924
++nTransactionsUpdated;
955
925
}
0 commit comments