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

Function LookUpOne

src/index/coinstatsindex.cpp:314–331  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

312}
313
314static bool LookUpOne(const CDBWrapper& db, const CBlockIndex* block_index, DBVal& result)
315{
316 // First check if the result is stored under the height index and the value
317 // there matches the block hash. This should be the case if the block is on
318 // the active chain.
319 std::pair<uint256, DBVal> read_out;
320 if (!db.Read(DBHeightKey(block_index->nHeight), read_out)) {
321 return false;
322 }
323 if (read_out.first == block_index->GetBlockHash()) {
324 result = std::move(read_out.second);
325 return true;
326 }
327
328 // If value at the height index corresponds to an different block, the
329 // result will be stored in the hash index.
330 return db.Read(DBHashKey(block_index->GetBlockHash()), result);
331}
332
333bool CoinStatsIndex::LookUpStats(const CBlockIndex* block_index, CCoinsStats& coins_stats) const
334{

Callers 2

LookUpStatsMethod · 0.85
InitMethod · 0.85

Calls 4

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

Tested by

no test coverage detected