diff options
author | stickies-v <stickies-v@protonmail.com> | 2022-10-24 18:03:07 +0100 |
---|---|---|
committer | stickies-v <stickies-v@protonmail.com> | 2022-12-13 15:44:45 +0000 |
commit | 47c4b1f52ab8d95d7deef83050bad49d1e3e5990 (patch) | |
tree | c8054013efcefa3c56a03dd30752a3fec02e3654 /src/txmempool.cpp | |
parent | 5481f65849313ff947f38433b1ac28285a7f7694 (diff) |
mempool: log/halt when CalculateMemPoolAncestors fails unexpectedly
When CalculateMemPoolAncestors fails unexpectedly (e.g. it exceeds
ancestor/descendant limits even though we expect no limits to be applied),
add an error log entry for increased visibility. For debug builds,
the application will even halt completely since this is not supposed
to happen.
Diffstat (limited to 'src/txmempool.cpp')
-rw-r--r-- | src/txmempool.cpp | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/src/txmempool.cpp b/src/txmempool.cpp index 4232c6d305..c83f89179b 100644 --- a/src/txmempool.cpp +++ b/src/txmempool.cpp @@ -349,8 +349,7 @@ void CTxMemPool::UpdateForRemoveFromMempool(const setEntries &entriesToRemove, b // mempool parents we'd calculate by searching, and it's important that // we use the cached notion of ancestor transactions as the set of // things to update for removal. - auto ancestors_result{CalculateMemPoolAncestors(entry, Limits::NoLimits(), /*fSearchForParents=*/false)}; - auto ancestors{std::move(ancestors_result).value_or(setEntries{})}; + auto ancestors{AssumeCalculateMemPoolAncestors(__func__, entry, Limits::NoLimits(), /*fSearchForParents=*/false)}; // Note that UpdateAncestorsOf severs the child links that point to // removeIt in the entries for the parents of removeIt. UpdateAncestorsOf(false, removeIt, ancestors); @@ -703,8 +702,7 @@ void CTxMemPool::check(const CCoinsViewCache& active_coins_tip, int64_t spendhei assert(setParentCheck.size() == it->GetMemPoolParentsConst().size()); assert(std::equal(setParentCheck.begin(), setParentCheck.end(), it->GetMemPoolParentsConst().begin(), comp)); // Verify ancestor state is correct. - auto ancestors_result{CalculateMemPoolAncestors(*it, Limits::NoLimits())}; - auto ancestors{std::move(ancestors_result).value_or(setEntries{})}; + auto ancestors{AssumeCalculateMemPoolAncestors(__func__, *it, Limits::NoLimits())}; uint64_t nCountCheck = ancestors.size() + 1; uint64_t nSizeCheck = it->GetTxSize(); CAmount nFeesCheck = it->GetModifiedFee(); @@ -865,8 +863,7 @@ void CTxMemPool::PrioritiseTransaction(const uint256& hash, const CAmount& nFeeD if (it != mapTx.end()) { mapTx.modify(it, [&nFeeDelta](CTxMemPoolEntry& e) { e.UpdateModifiedFee(nFeeDelta); }); // Now update all ancestors' modified fees with descendants - auto ancestors_result{CalculateMemPoolAncestors(*it, Limits::NoLimits(), /*fSearchForParents=*/false)}; - auto ancestors{std::move(ancestors_result).value_or(setEntries{})}; + auto ancestors{AssumeCalculateMemPoolAncestors(__func__, *it, Limits::NoLimits(), /*fSearchForParents=*/false)}; for (txiter ancestorIt : ancestors) { mapTx.modify(ancestorIt, [=](CTxMemPoolEntry& e){ e.UpdateDescendantState(0, nFeeDelta, 0);}); } @@ -1004,8 +1001,7 @@ int CTxMemPool::Expire(std::chrono::seconds time) void CTxMemPool::addUnchecked(const CTxMemPoolEntry &entry, bool validFeeEstimate) { - auto ancestors_result{CalculateMemPoolAncestors(entry, Limits::NoLimits())}; - auto ancestors{std::move(ancestors_result).value_or(CTxMemPool::setEntries{})}; + auto ancestors{AssumeCalculateMemPoolAncestors(__func__, entry, Limits::NoLimits())}; return addUnchecked(entry, ancestors, validFeeEstimate); } |