diff options
author | Fabian Jahr <fjahr@protonmail.com> | 2021-05-24 18:37:40 +0200 |
---|---|---|
committer | Fabian Jahr <fjahr@protonmail.com> | 2021-07-25 20:59:49 +0200 |
commit | 5b3d4e724f377834e24b1f014787cc7aa7fc30fe (patch) | |
tree | 4a1f36bdb564296454d08fcfeb09e30615b79f11 | |
parent | d4356d4e48f59c63894b68691cc21ed4892ee716 (diff) |
Index: Improve logging in coinstatsindex
More accurate logging of a warning should make clear if the recovery condition was hit while catching the results of the previous block.
-rw-r--r-- | src/index/coinstatsindex.cpp | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/src/index/coinstatsindex.cpp b/src/index/coinstatsindex.cpp index b3f5d75fb3..849ea752f2 100644 --- a/src/index/coinstatsindex.cpp +++ b/src/index/coinstatsindex.cpp @@ -122,9 +122,12 @@ bool CoinStatsIndex::WriteBlock(const CBlock& block, const CBlockIndex* pindex) uint256 expected_block_hash{pindex->pprev->GetBlockHash()}; if (read_out.first != expected_block_hash) { + LogPrintf("WARNING: previous block header belongs to unexpected block %s; expected %s\n", + read_out.first.ToString(), expected_block_hash.ToString()); + if (!m_db->Read(DBHashKey(expected_block_hash), read_out)) { - return error("%s: previous block header belongs to unexpected block %s; expected %s", - __func__, read_out.first.ToString(), expected_block_hash.ToString()); + return error("%s: previous block header not found; expected %s", + __func__, expected_block_hash.ToString()); } } @@ -392,9 +395,12 @@ bool CoinStatsIndex::ReverseBlock(const CBlock& block, const CBlockIndex* pindex uint256 expected_block_hash{pindex->pprev->GetBlockHash()}; if (read_out.first != expected_block_hash) { + LogPrintf("WARNING: previous block header belongs to unexpected block %s; expected %s\n", + read_out.first.ToString(), expected_block_hash.ToString()); + if (!m_db->Read(DBHashKey(expected_block_hash), read_out)) { - return error("%s: previous block header belongs to unexpected block %s; expected %s", - __func__, read_out.first.ToString(), expected_block_hash.ToString()); + return error("%s: previous block header not found; expected %s", + __func__, expected_block_hash.ToString()); } } } |