| 283 | } |
| 284 | |
| 285 | bool CTxMemPool::CheckPackageLimits(const Package& package, |
| 286 | uint64_t limitAncestorCount, |
| 287 | uint64_t limitAncestorSize, |
| 288 | uint64_t limitDescendantCount, |
| 289 | uint64_t limitDescendantSize, |
| 290 | std::string &errString) const |
| 291 | { |
| 292 | CTxMemPoolEntry::Parents staged_ancestors; |
| 293 | size_t total_size = 0; |
| 294 | for (const auto& tx : package) { |
| 295 | total_size += GetVirtualTransactionSize(*tx); |
| 296 | for (const auto& input : tx->vin) { |
| 297 | std::optional<txiter> piter = GetIter(input.prevout.hash); |
| 298 | if (piter) { |
| 299 | staged_ancestors.insert(**piter); |
| 300 | if (staged_ancestors.size() + package.size() > limitAncestorCount) { |
| 301 | errString = strprintf("too many unconfirmed parents [limit: %u]", limitAncestorCount); |
| 302 | return false; |
| 303 | } |
| 304 | } |
| 305 | } |
| 306 | } |
| 307 | // When multiple transactions are passed in, the ancestors and descendants of all transactions |
| 308 | // considered together must be within limits even if they are not interdependent. This may be |
| 309 | // stricter than the limits for each individual transaction. |
| 310 | setEntries setAncestors; |
| 311 | const auto ret = CalculateAncestorsAndCheckLimits(total_size, package.size(), |
| 312 | setAncestors, staged_ancestors, |
| 313 | limitAncestorCount, limitAncestorSize, |
| 314 | limitDescendantCount, limitDescendantSize, errString); |
| 315 | // It's possible to overestimate the ancestor/descendant totals. |
| 316 | if (!ret) errString.insert(0, "possibly "); |
| 317 | return ret; |
| 318 | } |
| 319 | |
| 320 | bool CTxMemPool::CalculateMemPoolAncestors(const CTxMemPoolEntry &entry, |
| 321 | setEntries &setAncestors, |
no test coverage detected