Skip to content

Commit 5b3d4e7

Browse files
committed
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.
1 parent d4356d4 commit 5b3d4e7

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

src/index/coinstatsindex.cpp

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -122,9 +122,12 @@ bool CoinStatsIndex::WriteBlock(const CBlock& block, const CBlockIndex* pindex)
122122

123123
uint256 expected_block_hash{pindex->pprev->GetBlockHash()};
124124
if (read_out.first != expected_block_hash) {
125+
LogPrintf("WARNING: previous block header belongs to unexpected block %s; expected %s\n",
126+
read_out.first.ToString(), expected_block_hash.ToString());
127+
125128
if (!m_db->Read(DBHashKey(expected_block_hash), read_out)) {
126-
return error("%s: previous block header belongs to unexpected block %s; expected %s",
127-
__func__, read_out.first.ToString(), expected_block_hash.ToString());
129+
return error("%s: previous block header not found; expected %s",
130+
__func__, expected_block_hash.ToString());
128131
}
129132
}
130133

@@ -392,9 +395,12 @@ bool CoinStatsIndex::ReverseBlock(const CBlock& block, const CBlockIndex* pindex
392395

393396
uint256 expected_block_hash{pindex->pprev->GetBlockHash()};
394397
if (read_out.first != expected_block_hash) {
398+
LogPrintf("WARNING: previous block header belongs to unexpected block %s; expected %s\n",
399+
read_out.first.ToString(), expected_block_hash.ToString());
400+
395401
if (!m_db->Read(DBHashKey(expected_block_hash), read_out)) {
396-
return error("%s: previous block header belongs to unexpected block %s; expected %s",
397-
__func__, read_out.first.ToString(), expected_block_hash.ToString());
402+
return error("%s: previous block header not found; expected %s",
403+
__func__, expected_block_hash.ToString());
398404
}
399405
}
400406
}

0 commit comments

Comments
 (0)