| 253 | } |
| 254 | |
| 255 | static bool CopyHeightIndexToHashIndex(CDBIterator& db_it, CDBBatch& batch, |
| 256 | const std::string& index_name, |
| 257 | int start_height, int stop_height) |
| 258 | { |
| 259 | DBHeightKey key(start_height); |
| 260 | db_it.Seek(key); |
| 261 | |
| 262 | for (int height = start_height; height <= stop_height; ++height) { |
| 263 | if (!db_it.GetKey(key) || key.height != height) { |
| 264 | return error("%s: unexpected key in %s: expected (%c, %d)", |
| 265 | __func__, index_name, DB_BLOCK_HEIGHT, height); |
| 266 | } |
| 267 | |
| 268 | std::pair<uint256, DBVal> value; |
| 269 | if (!db_it.GetValue(value)) { |
| 270 | return error("%s: unable to read value in %s at key (%c, %d)", |
| 271 | __func__, index_name, DB_BLOCK_HEIGHT, height); |
| 272 | } |
| 273 | |
| 274 | batch.Write(DBHashKey(value.first), std::move(value.second)); |
| 275 | |
| 276 | db_it.Next(); |
| 277 | } |
| 278 | return true; |
| 279 | } |
| 280 | |
| 281 | bool BlockFilterIndex::Rewind(const CBlockIndex* current_tip, const CBlockIndex* new_tip) |
| 282 | { |