@@ -122,8 +122,6 @@ void CTxMemPool::UpdateTransactionsFromBlock(const std::vector<uint256> &vHashes
122
122
// setMemPoolChildren will be updated, an assumption made in
123
123
// UpdateForDescendants.
124
124
for (const uint256 &hash : reverse_iterate (vHashesToUpdate)) {
125
- // we cache the in-mempool children to avoid duplicate updates
126
- setEntries setChildren;
127
125
// calculate children from mapNextTx
128
126
txiter it = mapTx.find (hash);
129
127
if (it == mapTx.end ()) {
@@ -132,17 +130,21 @@ void CTxMemPool::UpdateTransactionsFromBlock(const std::vector<uint256> &vHashes
132
130
auto iter = mapNextTx.lower_bound (COutPoint (hash, 0 ));
133
131
// First calculate the children, and update setMemPoolChildren to
134
132
// include them, and update their setMemPoolParents to include this tx.
135
- for (; iter != mapNextTx.end () && iter->first ->hash == hash; ++iter) {
136
- const uint256 &childHash = iter->second ->GetHash ();
137
- txiter childIter = mapTx.find (childHash);
138
- assert (childIter != mapTx.end ());
139
- // We can skip updating entries we've encountered before or that
140
- // are in the block (which are already accounted for).
141
- if (setChildren.insert (childIter).second && !setAlreadyIncluded.count (childHash)) {
142
- UpdateChild (it, childIter, true );
143
- UpdateParent (childIter, it, true );
133
+ // we cache the in-mempool children to avoid duplicate updates
134
+ {
135
+ const auto epoch = GetFreshEpoch ();
136
+ for (; iter != mapNextTx.end () && iter->first ->hash == hash; ++iter) {
137
+ const uint256 &childHash = iter->second ->GetHash ();
138
+ txiter childIter = mapTx.find (childHash);
139
+ assert (childIter != mapTx.end ());
140
+ // We can skip updating entries we've encountered before or that
141
+ // are in the block (which are already accounted for).
142
+ if (!visited (childIter) && !setAlreadyIncluded.count (childHash)) {
143
+ UpdateChild (it, childIter, true );
144
+ UpdateParent (childIter, it, true );
145
+ }
144
146
}
145
- }
147
+ } // release epoch guard for UpdateForDescendants
146
148
UpdateForDescendants (it, mapMemPoolDescendantsToUpdate, setAlreadyIncluded);
147
149
}
148
150
}
0 commit comments