Implement CCoinsViewErrorCatcher::HaveCoin
This commit is contained in:
2 files changed
+14
-3
No files matched your search
+13
-3
@@ -292,11 +292,13 @@ const Coin& AccessByTxid(const CCoinsViewCache& view, const uint256& txid)
|
|||||||
return coinEmpty;
|
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 {
|
try {
|
||||||
return CCoinsViewBacked::GetCoin(outpoint, coin);
|
return func();
|
||||||
} catch(const std::runtime_error& e) {
|
} catch(const std::runtime_error& e) {
|
||||||
for (const auto& f : m_err_callbacks) {
|
for (const auto& f : err_callbacks) {
|
||||||
f();
|
f();
|
||||||
}
|
}
|
||||||
LogPrintf("Error reading from database: %s\n", e.what());
|
LogPrintf("Error reading from database: %s\n", e.what());
|
||||||
@@ -307,3 +309,11 @@ bool CCoinsViewErrorCatcher::GetCoin(const COutPoint &outpoint, Coin &coin) cons
|
|||||||
std::abort();
|
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);
|
||||||
|
}
|
||||||
@@ -349,6 +349,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool GetCoin(const COutPoint &outpoint, Coin &coin) const override;
|
bool GetCoin(const COutPoint &outpoint, Coin &coin) const override;
|
||||||
|
bool HaveCoin(const COutPoint &outpoint) const override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/** A list of callbacks to execute upon leveldb read error. */
|
/** A list of callbacks to execute upon leveldb read error. */
|
||||||
|
|||||||
Reference in new issue
Block a user