MCPcopy Create free account
hub / github.com/ElementsProject/elements / CopyHeightIndexToHashIndex

Function CopyHeightIndexToHashIndex

src/index/blockfilterindex.cpp:255–279  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

253}
254
255static 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
281bool BlockFilterIndex::Rewind(const CBlockIndex* current_tip, const CBlockIndex* new_tip)
282{

Callers 1

RewindMethod · 0.70

Calls 7

errorFunction · 0.85
DBHashKeyClass · 0.70
SeekMethod · 0.45
GetKeyMethod · 0.45
GetValueMethod · 0.45
WriteMethod · 0.45
NextMethod · 0.45

Tested by

no test coverage detected