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