MCPcopy Create free account
hub / github.com/bitcoin/bitcoin / LookupFilterHeader

Method LookupFilterHeader

src/index/blockfilterindex.cpp:377–405  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

375}
376
377bool BlockFilterIndex::LookupFilterHeader(const CBlockIndex* block_index, uint256& header_out)
378{
379 LOCK(m_cs_headers_cache);
380
381 bool is_checkpoint{block_index->nHeight % CFCHECKPT_INTERVAL == 0};
382
383 if (is_checkpoint) {
384 // Try to find the block in the headers cache if this is a checkpoint height.
385 auto header = m_headers_cache.find(block_index->GetBlockHash());
386 if (header != m_headers_cache.end()) {
387 header_out = header->second;
388 return true;
389 }
390 }
391
392 DBVal entry;
393 if (!index_util::LookUpOne(*m_db, {block_index->GetBlockHash(), block_index->nHeight}, entry)) {
394 return false;
395 }
396
397 if (is_checkpoint &&
398 m_headers_cache.size() < CF_HEADERS_CACHE_MAX_SZ) {
399 // Add to the headers cache if this is a checkpoint height.
400 m_headers_cache.emplace(block_index->GetBlockHash(), entry.header);
401 }
402
403 header_out = entry.header;
404 return true;
405}
406
407bool BlockFilterIndex::LookupFilterRange(int start_height, const CBlockIndex* stop_index,
408 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 6

LookUpOneFunction · 0.85
findMethod · 0.80
emplaceMethod · 0.80
GetBlockHashMethod · 0.45
endMethod · 0.45
sizeMethod · 0.45

Tested by 2

CheckFilterLookupsFunction · 0.64
BOOST_FIXTURE_TEST_CASEFunction · 0.64