29 releases

0.14.1 Sep 12, 2024
0.13.0 Sep 20, 2022
0.12.1 Feb 7, 2022
0.11.1 Sep 30, 2021
0.2.5 Nov 6, 2017

#419 in Data structures

Download history 108379/week @ 2024-07-29 120033/week @ 2024-08-05 126183/week @ 2024-08-12 106649/week @ 2024-08-19 116123/week @ 2024-08-26 121219/week @ 2024-09-02 118374/week @ 2024-09-09 112147/week @ 2024-09-16 109229/week @ 2024-09-23 117603/week @ 2024-09-30 122867/week @ 2024-10-07 120065/week @ 2024-10-14 127288/week @ 2024-10-21 110919/week @ 2024-10-28 114066/week @ 2024-11-04 115669/week @ 2024-11-11

473,030 downloads per month
Used in 820 crates (7 directly)

MIT/Apache

66KB
1K SLoC

use hex_literal::hex;
use ethbloom::{Bloom, Input};

use std::str::FromStr;
let bloom = Bloom::from_str(
	"00000000000000000000000000000000\
	00000000100000000000000000000000\
	00000000000000000000000000000000\
	00000000000000000000000000000000\
	00000000000000000000000000000000\
	00000000000000000000000000000000\
	00000002020000000000000000000000\
	00000000000000000000000800000000\
	10000000000000000000000000000000\
	00000000000000000000001000000000\
	00000000000000000000000000000000\
	00000000000000000000000000000000\
	00000000000000000000000000000000\
	00000000000000000000000000000000\
	00000000000000000000000000000000\
	00000000000000000000000000000000"
).unwrap();
let address = hex!("ef2d6d194084c2de36e0dabfce45d046b37d1106");
let topic = hex!("02c69be41d0b7e40352fc85be1cd65eb03d40ef8427a0ca4596b1ead9a00e9fc");

let mut my_bloom = Bloom::default();
assert!(!my_bloom.contains_input(Input::Raw(&address)));
assert!(!my_bloom.contains_input(Input::Raw(&topic)));

my_bloom.accrue(Input::Raw(&address));
assert!(my_bloom.contains_input(Input::Raw(&address)));
assert!(!my_bloom.contains_input(Input::Raw(&topic)));

my_bloom.accrue(Input::Raw(&topic));
assert!(my_bloom.contains_input(Input::Raw(&address)));
assert!(my_bloom.contains_input(Input::Raw(&topic)));
assert_eq!(my_bloom, bloom);

Dependencies

~0–1MB
~16K SLoC