mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-03-23 14:10:15 +01:00
mempool: add AssumeCalculateMemPoolAncestors helper function
There are quite a few places that assume CalculateMemPoolAncestors will return a value without raising an error. This helper function adds logging (and Assume for debug builds) that ensures robustness but increases visibility in case of unexpected failures
This commit is contained in:
@@ -254,6 +254,20 @@ util::Result<CTxMemPool::setEntries> CTxMemPool::CalculateMemPoolAncestors(
|
||||
limits);
|
||||
}
|
||||
|
||||
CTxMemPool::setEntries CTxMemPool::AssumeCalculateMemPoolAncestors(
|
||||
std::string_view calling_fn_name,
|
||||
const CTxMemPoolEntry &entry,
|
||||
const Limits& limits,
|
||||
bool fSearchForParents /* = true */) const
|
||||
{
|
||||
auto result{Assume(CalculateMemPoolAncestors(entry, limits, fSearchForParents))};
|
||||
if (!result) {
|
||||
LogPrintLevel(BCLog::MEMPOOL, BCLog::Level::Error, "%s: CalculateMemPoolAncestors failed unexpectedly, continuing with empty ancestor set (%s)\n",
|
||||
calling_fn_name, util::ErrorString(result).original);
|
||||
}
|
||||
return std::move(result).value_or(CTxMemPool::setEntries{});
|
||||
}
|
||||
|
||||
void CTxMemPool::UpdateAncestorsOf(bool add, txiter it, setEntries &setAncestors)
|
||||
{
|
||||
const CTxMemPoolEntry::Parents& parents = it->GetMemPoolParentsConst();
|
||||
|
||||
Reference in New Issue
Block a user