@@ -150,16 +150,18 @@ void CTxMemPool::UpdateTransactionsFromBlock(const std::vector<uint256> &vHashes
150
150
UpdateForDescendants (it, mapMemPoolDescendantsToUpdate, setAlreadyIncluded);
151
151
}
152
152
}
153
- bool CTxMemPool::CalculateAncestorsAndCheckLimits (const CTxMemPoolEntry& entry,
153
+
154
+ bool CTxMemPool::CalculateAncestorsAndCheckLimits (size_t entry_size,
155
+ size_t entry_count,
154
156
setEntries& setAncestors,
155
- CTxMemPoolEntry::Parents & staged_ancestors,
157
+ CTxMemPoolEntry::Parents& staged_ancestors,
156
158
uint64_t limitAncestorCount,
157
159
uint64_t limitAncestorSize,
158
160
uint64_t limitDescendantCount,
159
161
uint64_t limitDescendantSize,
160
162
std::string &errString) const
161
163
{
162
- size_t totalSizeWithAncestors = entry. GetTxSize () ;
164
+ size_t totalSizeWithAncestors = entry_size ;
163
165
164
166
while (!staged_ancestors.empty ()) {
165
167
const CTxMemPoolEntry& stage = staged_ancestors.begin ()->get ();
@@ -169,10 +171,10 @@ bool CTxMemPool::CalculateAncestorsAndCheckLimits(const CTxMemPoolEntry& entry,
169
171
staged_ancestors.erase (stage);
170
172
totalSizeWithAncestors += stageit->GetTxSize ();
171
173
172
- if (stageit->GetSizeWithDescendants () + entry. GetTxSize () > limitDescendantSize) {
174
+ if (stageit->GetSizeWithDescendants () + entry_size > limitDescendantSize) {
173
175
errString = strprintf (" exceeds descendant size limit for tx %s [limit: %u]" , stageit->GetTx ().GetHash ().ToString (), limitDescendantSize);
174
176
return false ;
175
- } else if (stageit->GetCountWithDescendants () + 1 > limitDescendantCount) {
177
+ } else if (stageit->GetCountWithDescendants () + entry_count > limitDescendantCount) {
176
178
errString = strprintf (" too many descendants for tx %s [limit: %u]" , stageit->GetTx ().GetHash ().ToString (), limitDescendantCount);
177
179
return false ;
178
180
} else if (totalSizeWithAncestors > limitAncestorSize) {
@@ -188,7 +190,7 @@ bool CTxMemPool::CalculateAncestorsAndCheckLimits(const CTxMemPoolEntry& entry,
188
190
if (setAncestors.count (parent_it) == 0 ) {
189
191
staged_ancestors.insert (parent);
190
192
}
191
- if (staged_ancestors.size () + setAncestors.size () + 1 > limitAncestorCount) {
193
+ if (staged_ancestors.size () + setAncestors.size () + entry_count > limitAncestorCount) {
192
194
errString = strprintf (" too many unconfirmed ancestors [limit: %u]" , limitAncestorCount);
193
195
return false ;
194
196
}
@@ -231,7 +233,8 @@ bool CTxMemPool::CalculateMemPoolAncestors(const CTxMemPoolEntry &entry,
231
233
staged_ancestors = it->GetMemPoolParentsConst ();
232
234
}
233
235
234
- return CalculateAncestorsAndCheckLimits (entry, setAncestors, staged_ancestors,
236
+ return CalculateAncestorsAndCheckLimits (entry.GetTxSize (), /* entry_count */ 1 ,
237
+ setAncestors, staged_ancestors,
235
238
limitAncestorCount, limitAncestorSize,
236
239
limitDescendantCount, limitDescendantSize, errString);
237
240
}
0 commit comments