Module bip158
Expand description
BIP 158 Compact Block Filters for Light Clients.
This module implements a structure for compact filters on block data, for use in the BIP 157 light client protocol. The filter construction proposed is an alternative to Bloom filters, as used in BIP 37, that minimizes filter size by using Golomb-Rice coding for compression.
§Relevant BIPS
§Examples
ⓘ
fn get_script_for_coin(coin: &OutPoint) -> Result<ScriptBuf, BlockFilterError> {
// get utxo ...
}
// create a block filter for a block (server side)
let filter = BlockFilter::new_script_filter(&block, get_script_for_coin)?;
// or create a filter from known raw data
let filter = BlockFilter::new(content);
// read and evaluate a filter
let query: Iterator<Item=ScriptBuf> = // .. some scripts you care about
if filter.match_any(&block_hash, &mut query.map(|s| s.as_bytes())) {
// get this block
}
Structs§
- BitStream
Reader - Bitwise stream reader.
- BitStream
Writer - Bitwise stream writer.
- Block
Filter - A block filter, as described by BIP 158.
- Block
Filter Reader - Reads and interprets a block filter.
- Block
Filter Writer - Compiles and writes a block filter.
- Filter
Hash - Filter hash, as defined in BIP-157
- Filter
Header - Filter header, as defined in BIP-157
- GcsFilter
Reader - Golomb-Rice encoded filter reader.
- GcsFilter
Writer - Golomb-Rice encoded filter writer.
Enums§
- Error
- Errors for blockfilter.