txdb: Fix assert crash in new UTXO set cursor

Remove the mistaken assumption that GetKey returning false signifies
an internal database issue. It will return false when the key cannot
be deserialized into the (char,uint256) stanza, which indicates
that the cursor has reached a different kind of key.

Fixes bug #7890 introduced in #7756.
pull/262/head
Wladimir J. van der Laan 9 years ago
parent 73fc922ed6
commit a3310b4d48

@ -134,12 +134,8 @@ bool CCoinsViewDBCursor::Valid() const
void CCoinsViewDBCursor::Next() void CCoinsViewDBCursor::Next()
{ {
pcursor->Next(); pcursor->Next();
if (pcursor->Valid()) { if (!pcursor->Valid() || !pcursor->GetKey(keyTmp))
bool ok = pcursor->GetKey(keyTmp);
assert(ok); // If GetKey fails here something must be wrong with underlying database, we cannot handle that here
} else {
keyTmp.first = 0; // Invalidate cached key after last record so that Valid() and GetKey() return false keyTmp.first = 0; // Invalidate cached key after last record so that Valid() and GetKey() return false
}
} }
bool CBlockTreeDB::WriteBatchSync(const std::vector<std::pair<int, const CBlockFileInfo*> >& fileInfo, int nLastFile, const std::vector<const CBlockIndex*>& blockinfo) { bool CBlockTreeDB::WriteBatchSync(const std::vector<std::pair<int, const CBlockFileInfo*> >& fileInfo, int nLastFile, const std::vector<const CBlockIndex*>& blockinfo) {

Loading…
Cancel
Save