Module filter_persistence

Module filter_persistence 

Source
Expand description

Cuckoo filter persistence for fast startup.

Stores filter state alongside the merkle root that was current when the filter was saved. On startup, if the current merkle root matches the saved root, the filter is immediately trusted.

§Storage

Uses the WAL SQLite database for storage (reuses existing connection).

CREATE TABLE cf_state (
    filter_id TEXT PRIMARY KEY,      -- "l2" or "l3"
    filter_bytes BLOB NOT NULL,      -- Exported filter data
    merkle_root BLOB NOT NULL,       -- 32-byte root hash when saved
    entry_count INTEGER NOT NULL,    -- Number of entries at save time
    saved_at INTEGER NOT NULL        -- Unix timestamp
);

Structs§

FilterPersistence
Cuckoo filter persistence manager.
SavedFilterState
Saved filter state

Constants§

L2_FILTER_ID
Filter IDs for persistence
L3_FILTER_ID