| 238 | }; |
| 239 | |
| 240 | std::unique_ptr<CCoinsViewCursor> CCoinsViewDB::Cursor() const |
| 241 | { |
| 242 | auto i = std::make_unique<CCoinsViewDBCursor>( |
| 243 | const_cast<CDBWrapper&>(*m_db).NewIterator(), GetBestBlock()); |
| 244 | /* It seems that there are no "const iterators" for LevelDB. Since we |
| 245 | only need read operations on it, use a const-cast to get around |
| 246 | that restriction. */ |
| 247 | i->pcursor->Seek(DB_COIN); |
| 248 | // Cache key of first record |
| 249 | if (i->pcursor->Valid()) { |
| 250 | CoinEntry entry(&i->keyTmp.second); |
| 251 | i->pcursor->GetKey(entry); |
| 252 | i->keyTmp.first = entry.key; |
| 253 | } else { |
| 254 | i->keyTmp.first = 0; // Make sure Valid() and GetKey() return false |
| 255 | } |
| 256 | return i; |
| 257 | } |
| 258 | |
| 259 | bool CCoinsViewDBCursor::GetKey(COutPoint &key) const |
| 260 | { |