mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-12 15:09:59 +01:00
Implement CCoinsViewErrorCatcher::HaveCoin
This commit is contained in:
@@ -292,11 +292,13 @@ const Coin& AccessByTxid(const CCoinsViewCache& view, const uint256& txid)
|
||||
return coinEmpty;
|
||||
}
|
||||
|
||||
bool CCoinsViewErrorCatcher::GetCoin(const COutPoint &outpoint, Coin &coin) const {
|
||||
template <typename Func>
|
||||
static bool ExecuteBackedWrapper(Func func, const std::vector<std::function<void()>>& err_callbacks)
|
||||
{
|
||||
try {
|
||||
return CCoinsViewBacked::GetCoin(outpoint, coin);
|
||||
return func();
|
||||
} catch(const std::runtime_error& e) {
|
||||
for (const auto& f : m_err_callbacks) {
|
||||
for (const auto& f : err_callbacks) {
|
||||
f();
|
||||
}
|
||||
LogPrintf("Error reading from database: %s\n", e.what());
|
||||
@@ -307,3 +309,11 @@ bool CCoinsViewErrorCatcher::GetCoin(const COutPoint &outpoint, Coin &coin) cons
|
||||
std::abort();
|
||||
}
|
||||
}
|
||||
|
||||
bool CCoinsViewErrorCatcher::GetCoin(const COutPoint &outpoint, Coin &coin) const {
|
||||
return ExecuteBackedWrapper([&]() { return CCoinsViewBacked::GetCoin(outpoint, coin); }, m_err_callbacks);
|
||||
}
|
||||
|
||||
bool CCoinsViewErrorCatcher::HaveCoin(const COutPoint &outpoint) const {
|
||||
return ExecuteBackedWrapper([&]() { return CCoinsViewBacked::HaveCoin(outpoint); }, m_err_callbacks);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user