diff --git a/src/bloom.rs b/src/bloom.rs index fed8a1654..3c59713ac 100644 --- a/src/bloom.rs +++ b/src/bloom.rs @@ -1,15 +1,10 @@ //! Simple Bloom Filter +use crate::bloom_hash_index::BloomHashIndex; use bv::BitVec; use rand::{self, Rng}; use std::cmp; use std::marker::PhantomData; -/// Generate a stable hash of `self` for each `hash_index` -/// Best effort can be made for uniqueness of each hash. -pub trait BloomHashIndex { - fn hash(&self, hash_index: u64) -> u64; -} - #[derive(Serialize, Deserialize, Default, Clone, Debug, PartialEq)] pub struct Bloom { pub keys: Vec, diff --git a/src/crds_traits_impls.rs b/src/bloom_hash_index.rs similarity index 75% rename from src/crds_traits_impls.rs rename to src/bloom_hash_index.rs index a885e43b9..a6c493193 100644 --- a/src/crds_traits_impls.rs +++ b/src/bloom_hash_index.rs @@ -1,4 +1,3 @@ -use crate::bloom::BloomHashIndex; use solana_sdk::hash::Hash; use solana_sdk::pubkey::Pubkey; @@ -13,6 +12,12 @@ fn slice_hash(slice: &[u8], hash_index: u64) -> u64 { rv } +/// Generate a stable hash of `self` for each `hash_index` +/// Best effort can be made for uniqueness of each hash. +pub trait BloomHashIndex { + fn hash(&self, hash_index: u64) -> u64; +} + impl BloomHashIndex for Pubkey { fn hash(&self, hash_index: u64) -> u64 { slice_hash(self.as_ref(), hash_index) diff --git a/src/lib.rs b/src/lib.rs index 853bb0fc7..dadd32d35 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -14,6 +14,7 @@ pub mod bank; pub mod banking_stage; pub mod blob_fetch_stage; pub mod bloom; +pub mod bloom_hash_index; pub mod broadcast_service; #[cfg(feature = "chacha")] pub mod chacha; @@ -26,7 +27,6 @@ pub mod crds_gossip; pub mod crds_gossip_error; pub mod crds_gossip_pull; pub mod crds_gossip_push; -pub mod crds_traits_impls; pub mod crds_value; #[macro_use] pub mod contact_info;