Struct bitcoin_bloom::BloomFilter
source · pub struct BloomFilter { /* private fields */ }
Expand description
| BloomFilter is a probabilistic filter | which SPV clients provide so that we | can filter the transactions we send | them. | | This allows for significantly more | efficient transaction and block downloads. | | Because bloom filters are probabilistic, | a SPV node can increase the false- positive | rate, making us send it transactions | which aren’t actually its, allowing | clients to trade more bandwidth for | more privacy by obfuscating which keys | are controlled by them. |
Implementations§
source§impl BloomFilter
impl BloomFilter
sourcepub fn new(
n_elements: u32,
n_fp_rate: f64,
n_tweak_in: u32,
n_flags_in: u8
) -> Self
pub fn new( n_elements: u32, n_fp_rate: f64, n_tweak_in: u32, n_flags_in: u8 ) -> Self
| Creates a new bloom filter which will | provide the given fp rate when filled | with the given number of elements | | ———– | @note | | if the given parameters will result | in a filter outside the bounds of the | protocol limits, the filter created | will be as close to the given parameters | as possible within the protocol limits. | | This will apply if nFPRate is very low | or nElements is unreasonably high. | nTweak is a constant which is added to | the seed value passed to the hash function | | It should generally always be a random | value (and is largely only exposed for | unit testing) nFlags should be one of | the BLOOM_UPDATE_* enums (not _MASK) |
pub fn hash(&self, n_hash_num: u32, data_to_hash: &[u8]) -> u32
pub fn insert_key(&mut self, key: &[u8])
pub fn insert_outpoint(&mut self, outpoint: &OutPoint)
pub fn contains_key(&self, key: &[u8]) -> bool
pub fn contains_outpoint(&self, outpoint: &OutPoint) -> bool
sourcepub fn is_within_size_constraints(&self) -> bool
pub fn is_within_size_constraints(&self) -> bool
| True if the size is <= | MAX_BLOOM_FILTER_SIZE and the number of | hash functions is <= MAX_HASH_FUNCS (catch | a filter which was just deserialized which | was too big)
sourcepub fn is_relevant_and_update(&mut self, tx: &Transaction) -> bool
pub fn is_relevant_and_update(&mut self, tx: &Transaction) -> bool
| Also adds any outputs which match the | filter to the filter (to match their | spending txes) |
Trait Implementations§
source§impl Clone for BloomFilter
impl Clone for BloomFilter
source§fn clone(&self) -> BloomFilter
fn clone(&self) -> BloomFilter
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more