#bloom-filter #input #vapory #tetsy #literals #hex

no-std vapbloom

Tetsy通用VaporyBloom过滤器

显示软件包…

4个版本 (2个破坏性)

0.11.1 2021年6月8日
0.11.0 2021年2月18日
0.10.0 2021年3月10日
0.8.0 2021年2月20日

#11 in #vapory

Download history 94/week @ 2024-04-06 167/week @ 2024-04-13 135/week @ 2024-04-20 88/week @ 2024-04-27 85/week @ 2024-05-04 115/week @ 2024-05-11 108/week @ 2024-05-18 120/week @ 2024-05-25 100/week @ 2024-06-01 57/week @ 2024-06-08 89/week @ 2024-06-15 129/week @ 2024-06-22 44/week @ 2024-06-29 43/week @ 2024-07-06 151/week @ 2024-07-13 83/week @ 2024-07-20

345 每月下载次数
用于 70 个软件包 (3 直接)

MIT/Apache

65KB
1K SLoC

use hex_literal::hex;
use vapbloom::{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);

依赖关系

~91–560KB
~10K SLoC