| 170 | } |
| 171 | |
| 172 | CCoinsViewCursor *CCoinsViewDB::Cursor() const |
| 173 | { |
| 174 | CCoinsViewDBCursor *i = new CCoinsViewDBCursor(const_cast<CDBWrapper&>(db).NewIterator(), GetBestBlock()); |
| 175 | /* It seems that there are no "const iterators" for LevelDB. Since we |
| 176 | only need read operations on it, use a const-cast to get around |
| 177 | that restriction. */ |
| 178 | i->pcursor->Seek(DB_COIN); |
| 179 | // Cache key of first record |
| 180 | if (i->pcursor->Valid()) { |
| 181 | CoinEntry entry(&i->keyTmp.second); |
| 182 | i->pcursor->GetKey(entry); |
| 183 | i->keyTmp.first = entry.key; |
| 184 | } else { |
| 185 | i->keyTmp.first = 0; // Make sure Valid() and GetKey() return false |
| 186 | } |
| 187 | return i; |
| 188 | } |
| 189 | |
| 190 | bool CCoinsViewDBCursor::GetKey(COutPoint &key) const |
| 191 | { |
no test coverage detected