28 releases

0.13.0 Sep 20, 2022
0.12.1 Feb 7, 2022
0.11.1 Sep 30, 2021
0.11.0 Jan 27, 2021
0.2.5 Nov 6, 2017

#294 in Magic Beans

Download history 91125/week @ 2023-12-11 84546/week @ 2023-12-18 39912/week @ 2023-12-25 66391/week @ 2024-01-01 90366/week @ 2024-01-08 100153/week @ 2024-01-15 102995/week @ 2024-01-22 112357/week @ 2024-01-29 97583/week @ 2024-02-05 100595/week @ 2024-02-12 105467/week @ 2024-02-19 101576/week @ 2024-02-26 93927/week @ 2024-03-04 101653/week @ 2024-03-11 101943/week @ 2024-03-18 97305/week @ 2024-03-25

399,929 downloads per month
Used in 609 crates (7 directly)

MIT/Apache

65KB
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.1–1MB
~17K SLoC