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

Function CopyHeightIndexToHashIndex

src/index/coinstatsindex.cpp:250–274  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

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