aboutsummaryrefslogtreecommitdiff
path: root/src/coins.cpp
diff options
context:
space:
mode:
authorJames O'Beirne <james.obeirne@gmail.com>2019-03-27 14:17:13 -0400
committerJames O'Beirne <james.obeirne@gmail.com>2019-07-21 21:00:31 -0400
commit4f050b91c706181084b9288b8a87b7b637e4e4f7 (patch)
tree04d89c31739b0fd905dcab774726852d9653f40f /src/coins.cpp
parent2679bb8919b5089f8067ccfd94f766747b8df671 (diff)
move-onlyish: move CCoinsViewErrorCatcher out of init.cpp
and into coins.cpp. This move is necessary so that we can later include a CCoinsViewErrorCatcher instance under CChainState. Co-authored-by: MarcoFalke <falke.marco@gmail.com>
Diffstat (limited to 'src/coins.cpp')
-rw-r--r--src/coins.cpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/coins.cpp b/src/coins.cpp
index 3ef9e0463c..6b85edd01a 100644
--- a/src/coins.cpp
+++ b/src/coins.cpp
@@ -5,6 +5,7 @@
#include <coins.h>
#include <consensus/consensus.h>
+#include <logging.h>
#include <random.h>
#include <version.h>
@@ -258,3 +259,19 @@ const Coin& AccessByTxid(const CCoinsViewCache& view, const uint256& txid)
}
return coinEmpty;
}
+
+bool CCoinsViewErrorCatcher::GetCoin(const COutPoint &outpoint, Coin &coin) const {
+ try {
+ return CCoinsViewBacked::GetCoin(outpoint, coin);
+ } catch(const std::runtime_error& e) {
+ for (auto f : m_err_callbacks) {
+ f();
+ }
+ LogPrintf("Error reading from database: %s\n", e.what());
+ // Starting the shutdown sequence and returning false to the caller would be
+ // interpreted as 'entry not found' (as opposed to unable to read data), and
+ // could lead to invalid interpretation. Just exit immediately, as we can't
+ // continue anyway, and all writes should be atomic.
+ std::abort();
+ }
+}