Fix: make CCoinsViewDbCursor::Seek work for missing keys

Thanks to Suhas Daftuar for figuring this out.
This commit is contained in:
Pieter Wuille authored and Gregory Maxwell committed 2017-05-23 22:25:52 +00:00
1 parent 4cb8757aae
commit 822755a424
1 file changed
+5 -1
+5 -1
View File
@@ -98,7 +98,11 @@ CCoinsViewCursor *CCoinsViewDB::Cursor() const
that restriction. */ that restriction. */
i->pcursor->Seek(DB_COINS); i->pcursor->Seek(DB_COINS);
// Cache key of first record // Cache key of first record
i->pcursor->GetKey(i->keyTmp); if (i->pcursor->Valid()) {
i->pcursor->GetKey(i->keyTmp);
} else {
i->keyTmp.first = 0; // Make sure Valid() and GetKey() return false
}
return i; return i;
} }