MCPcopy Create free account
hub / github.com/ElementsProject/elements / CalculateAncestorsAndCheckLimits

Method CalculateAncestorsAndCheckLimits

src/txmempool.cpp:236–283  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

234}
235
236bool CTxMemPool::CalculateAncestorsAndCheckLimits(size_t entry_size,
237 size_t entry_count,
238 setEntries& setAncestors,
239 CTxMemPoolEntry::Parents& staged_ancestors,
240 uint64_t limitAncestorCount,
241 uint64_t limitAncestorSize,
242 uint64_t limitDescendantCount,
243 uint64_t limitDescendantSize,
244 std::string &errString) const
245{
246 size_t totalSizeWithAncestors = entry_size;
247
248 while (!staged_ancestors.empty()) {
249 const CTxMemPoolEntry& stage = staged_ancestors.begin()->get();
250 txiter stageit = mapTx.iterator_to(stage);
251
252 setAncestors.insert(stageit);
253 staged_ancestors.erase(stage);
254 totalSizeWithAncestors += stageit->GetTxSize();
255
256 if (stageit->GetSizeWithDescendants() + entry_size > limitDescendantSize) {
257 errString = strprintf("exceeds descendant size limit for tx %s [limit: %u]", stageit->GetTx().GetHash().ToString(), limitDescendantSize);
258 return false;
259 } else if (stageit->GetCountWithDescendants() + entry_count > limitDescendantCount) {
260 errString = strprintf("too many descendants for tx %s [limit: %u]", stageit->GetTx().GetHash().ToString(), limitDescendantCount);
261 return false;
262 } else if (totalSizeWithAncestors > limitAncestorSize) {
263 errString = strprintf("exceeds ancestor size limit [limit: %u]", limitAncestorSize);
264 return false;
265 }
266
267 const CTxMemPoolEntry::Parents& parents = stageit->GetMemPoolParentsConst();
268 for (const CTxMemPoolEntry& parent : parents) {
269 txiter parent_it = mapTx.iterator_to(parent);
270
271 // If this is a new ancestor, add it.
272 if (setAncestors.count(parent_it) == 0) {
273 staged_ancestors.insert(parent);
274 }
275 if (staged_ancestors.size() + setAncestors.size() + entry_count > limitAncestorCount) {
276 errString = strprintf("too many unconfirmed ancestors [limit: %u]", limitAncestorCount);
277 return false;
278 }
279 }
280 }
281
282 return true;
283}
284
285bool CTxMemPool::CheckPackageLimits(const Package& package,
286 uint64_t limitAncestorCount,

Callers

nothing calls this directly

Calls 13

GetTxMethod · 0.80
countMethod · 0.80
emptyMethod · 0.45
getMethod · 0.45
beginMethod · 0.45
insertMethod · 0.45
eraseMethod · 0.45
GetTxSizeMethod · 0.45
ToStringMethod · 0.45
GetHashMethod · 0.45

Tested by

no test coverage detected