Skip to content

Commit

Permalink
index: add start_height to blockfilterindex
Browse files Browse the repository at this point in the history
Allow start_height to be specified when creating a blockfilterindex
  • Loading branch information
josibake committed Jan 31, 2024
1 parent 3b40c19 commit c7682aa
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
11 changes: 8 additions & 3 deletions src/index/blockfilterindex.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,13 @@ struct DBHashKey {
static std::map<BlockFilterType, BlockFilterIndex> g_filter_indexes;

BlockFilterIndex::BlockFilterIndex(std::unique_ptr<interfaces::Chain> chain, BlockFilterType filter_type,
size_t n_cache_size, bool f_memory, bool f_wipe)
: BaseIndex(std::move(chain), BlockFilterTypeName(filter_type) + " block filter index")
size_t n_cache_size, bool f_memory, bool f_wipe, int start_height)
: BaseIndex(
std::move(chain),
BlockFilterTypeName(filter_type) + " block filter index",
start_height
)
, m_start_height(start_height)
, m_filter_type(filter_type)
{
const std::string& filter_name = BlockFilterTypeName(filter_type);
Expand Down Expand Up @@ -220,7 +225,7 @@ bool BlockFilterIndex::CustomAppend(const interfaces::BlockInfo& block)
CBlockUndo block_undo;
uint256 prev_header;

if (block.height > 0) {
if (block.height > m_start_height) {
// pindex variable gives indexing code access to node internals. It
// will be removed in upcoming commit
const CBlockIndex* pindex = WITH_LOCK(cs_main, return m_chainstate->m_blockman.LookupBlockIndex(block.hash));
Expand Down
5 changes: 4 additions & 1 deletion src/index/blockfilterindex.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ static constexpr int CFCHECKPT_INTERVAL = 1000;
class BlockFilterIndex final : public BaseIndex
{
private:
const int m_start_height;
BlockFilterType m_filter_type;
std::unique_ptr<BaseIndex::DB> m_db;

Expand Down Expand Up @@ -58,7 +59,9 @@ class BlockFilterIndex final : public BaseIndex
public:
/** Constructs the index, which becomes available to be queried. */
explicit BlockFilterIndex(std::unique_ptr<interfaces::Chain> chain, BlockFilterType filter_type,
size_t n_cache_size, bool f_memory = false, bool f_wipe = false);
size_t n_cache_size, bool f_memory = false, bool f_wipe = false, int start_height = 0);

int GetStartHeight() const { return m_start_height; }

BlockFilterType GetFilterType() const { return m_filter_type; }

Expand Down

0 comments on commit c7682aa

Please sign in to comment.