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

#27 in #bloom

Download history 108069/week @ 2024-08-21 115552/week @ 2024-08-28 123582/week @ 2024-09-04 119224/week @ 2024-09-11 109739/week @ 2024-09-18 109027/week @ 2024-09-25 122380/week @ 2024-10-02 119834/week @ 2024-10-09 125903/week @ 2024-10-16 121842/week @ 2024-10-23 112730/week @ 2024-10-30 110498/week @ 2024-11-06 130816/week @ 2024-11-13 128915/week @ 2024-11-20 131142/week @ 2024-11-27 114464/week @ 2024-12-04

529,890 downloads per month
Used in 832 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