Copyright | No rights reserved |
---|---|
License | MIT |
Maintainer | jprupp@protonmail.ch |
Stability | experimental |
Portability | POSIX |
Safe Haskell | None |
Language | Haskell2010 |
Bloom filters are used to reduce data transfer when synchronizing thin cients. When bloom filters are used a client will obtain filtered blocks that only contain transactions that pass the bloom filter. Transactions announced via inv messages also pass the filter.
Synopsis
- data BloomFlags
- data BloomFilter = BloomFilter {
- bloomData :: !(Seq Word8)
- bloomHashFuncs :: !Word32
- bloomTweak :: !Word32
- bloomFlags :: !BloomFlags
- newtype FilterLoad = FilterLoad {}
- newtype FilterAdd = FilterAdd {}
- bloomCreate :: Int -> Double -> Word32 -> BloomFlags -> BloomFilter
- bloomInsert :: BloomFilter -> ByteString -> BloomFilter
- bloomContains :: BloomFilter -> ByteString -> Bool
- isBloomValid :: BloomFilter -> Bool
- isBloomEmpty :: BloomFilter -> Bool
- isBloomFull :: BloomFilter -> Bool
- acceptsFilters :: Word64 -> Bool
- bloomRelevantUpdate :: BloomFilter -> Tx -> Maybe BloomFilter
Bloom Filters
data BloomFlags Source #
The bloom flags are used to tell the remote peer how to auto-update the provided bloom filter.
BloomUpdateNone | never update |
BloomUpdateAll | auto-update on all outputs |
BloomUpdateP2PubKeyOnly | auto-update on pay-to-pubkey or pay-to-multisig (default) |
Instances
data BloomFilter Source #
A bloom filter is a probabilistic data structure that SPV clients send to other peers to filter the set of transactions received from them. Bloom filters can have false positives but not false negatives. Some transactions that pass the filter may not be relevant to the receiving peer. By controlling the false positive rate, SPV nodes can trade off bandwidth versus privacy.
BloomFilter | |
|
Instances
newtype FilterLoad Source #
Set a new bloom filter on the peer connection.
Instances
Add the given data element to the connections current filter without requiring a completely new one to be set.
Instances
Eq FilterAdd Source # | |
Read FilterAdd Source # | |
Show FilterAdd Source # | |
Generic FilterAdd Source # | |
Serialize FilterAdd Source # | |
NFData FilterAdd Source # | |
Defined in Haskoin.Network.Bloom | |
type Rep FilterAdd Source # | |
Defined in Haskoin.Network.Bloom type Rep FilterAdd = D1 ('MetaData "FilterAdd" "Haskoin.Network.Bloom" "haskoin-core-0.19.0-inplace" 'True) (C1 ('MetaCons "FilterAdd" 'PrefixI 'True) (S1 ('MetaSel ('Just "getFilterData") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 ByteString))) |
:: Int | number of elements |
-> Double | false positive rate |
-> Word32 | random nonce (tweak) for the hash function |
-> BloomFlags | bloom filter flags |
-> BloomFilter | bloom filter |
Build a bloom filter that will provide the given false positive rate when the given number of elements have been inserted.
:: BloomFilter | Original bloom filter |
-> ByteString | New data to insert |
-> BloomFilter | Bloom filter containing the new data |
Insert arbitrary data into a bloom filter. Returns the new bloom filter containing the new data.
:: BloomFilter | Bloom filter |
-> ByteString | Data that will be checked against the given bloom filter |
-> Bool | Returns True if the data matches the filter |
Tests if some arbitrary data matches the filter. This can be either because the data was inserted into the filter or because it is a false positive.
:: BloomFilter | Bloom filter to test |
-> Bool | True if the given filter is valid |
Tests if a given bloom filter is valid.
isBloomEmpty :: BloomFilter -> Bool Source #
Returns True if the filter is empty (all bytes set to 0x00)
isBloomFull :: BloomFilter -> Bool Source #
Returns True if the filter is full (all bytes set to 0xff)
acceptsFilters :: Word64 -> Bool Source #
Does the peer with these version services accept bloom filters?
:: BloomFilter | Bloom filter |
-> Tx | Tx that may (or may not) have relevant outputs |
-> Maybe BloomFilter | Returns an updated bloom filter adding relevant output |
Checks if any of the outputs of a tx is in the current bloom filter. If it is, add the txid and vout as an outpoint (i.e. so that a future tx that spends the output won't be missed).