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

Function LookupOne

src/index/blockfilterindex.cpp:304–320  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

302}
303
304static bool LookupOne(const CDBWrapper& db, const CBlockIndex* block_index, DBVal& result)
305{
306 // First check if the result is stored under the height index and the value there matches the
307 // block hash. This should be the case if the block is on the active chain.
308 std::pair<uint256, DBVal> read_out;
309 if (!db.Read(DBHeightKey(block_index->nHeight), read_out)) {
310 return false;
311 }
312 if (read_out.first == block_index->GetBlockHash()) {
313 result = std::move(read_out.second);
314 return true;
315 }
316
317 // If value at the height index corresponds to an different block, the result will be stored in
318 // the hash index.
319 return db.Read(DBHashKey(block_index->GetBlockHash()), result);
320}
321
322static bool LookupRange(CDBWrapper& db, const std::string& index_name, int start_height,
323 const CBlockIndex* stop_index, std::vector<DBVal>& results)

Callers 2

LookupFilterMethod · 0.85
LookupFilterHeaderMethod · 0.85

Calls 4

DBHeightKeyClass · 0.70
DBHashKeyClass · 0.70
ReadMethod · 0.45
GetBlockHashMethod · 0.45

Tested by

no test coverage detected