Changeset View
Changeset View
Standalone View
Standalone View
src/txdb.cpp
Show First 20 Lines • Show All 95 Lines • ▼ Show 20 Lines | CCoinsViewDBCursor *i = new CCoinsViewDBCursor( | ||||
const_cast<CDBWrapper *>(&db)->NewIterator(), GetBestBlock()); | const_cast<CDBWrapper *>(&db)->NewIterator(), GetBestBlock()); | ||||
/** | /** | ||||
* It seems that there are no "const iterators" for LevelDB. Since we only | * It seems that there are no "const iterators" for LevelDB. Since we only | ||||
* need read operations on it, use a const-cast to get around that | * need read operations on it, use a const-cast to get around that | ||||
* restriction. | * restriction. | ||||
*/ | */ | ||||
i->pcursor->Seek(DB_COINS); | i->pcursor->Seek(DB_COINS); | ||||
// Cache key of first record | // Cache key of first record | ||||
if (i->pcursor->Valid()) { | |||||
i->pcursor->GetKey(i->keyTmp); | i->pcursor->GetKey(i->keyTmp); | ||||
} else { | |||||
// Make sure Valid() and GetKey() return false | |||||
i->keyTmp.first = 0; | |||||
} | |||||
return i; | return i; | ||||
} | } | ||||
bool CCoinsViewDBCursor::GetKey(uint256 &key) const { | bool CCoinsViewDBCursor::GetKey(uint256 &key) const { | ||||
// Return cached key | // Return cached key | ||||
if (keyTmp.first == DB_COINS) { | if (keyTmp.first == DB_COINS) { | ||||
key = keyTmp.second; | key = keyTmp.second; | ||||
return true; | return true; | ||||
▲ Show 20 Lines • Show All 112 Lines • Show Last 20 Lines |