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

Method LookupFilterHeader

src/index/blockfilterindex.cpp:387–415  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

385}
386
387bool BlockFilterIndex::LookupFilterHeader(const CBlockIndex* block_index, uint256& header_out)
388{
389 LOCK(m_cs_headers_cache);
390
391 bool is_checkpoint{block_index->nHeight % CFCHECKPT_INTERVAL == 0};
392
393 if (is_checkpoint) {
394 // Try to find the block in the headers cache if this is a checkpoint height.
395 auto header = m_headers_cache.find(block_index->GetBlockHash());
396 if (header != m_headers_cache.end()) {
397 header_out = header->second;
398 return true;
399 }
400 }
401
402 DBVal entry;
403 if (!LookupOne(*m_db, block_index, entry)) {
404 return false;
405 }
406
407 if (is_checkpoint &&
408 m_headers_cache.size() < CF_HEADERS_CACHE_MAX_SZ) {
409 // Add to the headers cache if this is a checkpoint height.
410 m_headers_cache.emplace(block_index->GetBlockHash(), entry.header);
411 }
412
413 header_out = entry.header;
414 return true;
415}
416
417bool BlockFilterIndex::LookupFilterRange(int start_height, const CBlockIndex* stop_index,
418 std::vector<BlockFilter>& filters_out) const

Callers 6

rest_filter_headerFunction · 0.80
ProcessGetCFHeadersMethod · 0.80
ProcessGetCFCheckPtMethod · 0.80
CheckFilterLookupsFunction · 0.80
BOOST_FIXTURE_TEST_CASEFunction · 0.80
getblockfilterFunction · 0.80

Calls 5

LookupOneFunction · 0.85
findMethod · 0.80
GetBlockHashMethod · 0.45
endMethod · 0.45
sizeMethod · 0.45

Tested by 2

CheckFilterLookupsFunction · 0.64
BOOST_FIXTURE_TEST_CASEFunction · 0.64