pub struct BloomState { /* private fields */ }Expand description
State for managing Bloom filter announcements.
Tracks local filter state and what needs to be sent to peers.
Implementations§
Source§impl BloomState
impl BloomState
Sourcepub fn own_node_addr(&self) -> &NodeAddr
pub fn own_node_addr(&self) -> &NodeAddr
Get the node’s own ID.
Sourcepub fn is_leaf_only(&self) -> bool
pub fn is_leaf_only(&self) -> bool
Check if this is a leaf-only node.
Sourcepub fn next_sequence(&mut self) -> u64
pub fn next_sequence(&mut self) -> u64
Increment and return the next sequence number.
Sourcepub fn update_debounce_ms(&self) -> u64
pub fn update_debounce_ms(&self) -> u64
Get the update debounce interval in milliseconds.
Sourcepub fn set_update_debounce_ms(&mut self, ms: u64)
pub fn set_update_debounce_ms(&mut self, ms: u64)
Set the update debounce interval.
Sourcepub fn add_leaf_dependent(&mut self, node_addr: NodeAddr)
pub fn add_leaf_dependent(&mut self, node_addr: NodeAddr)
Add a leaf dependent that we’ll include in our filter.
Sourcepub fn remove_leaf_dependent(&mut self, node_addr: &NodeAddr) -> bool
pub fn remove_leaf_dependent(&mut self, node_addr: &NodeAddr) -> bool
Remove a leaf dependent.
Sourcepub fn leaf_dependents(&self) -> &HashSet<NodeAddr>
pub fn leaf_dependents(&self) -> &HashSet<NodeAddr>
Get the set of leaf dependents.
Sourcepub fn leaf_dependent_count(&self) -> usize
pub fn leaf_dependent_count(&self) -> usize
Number of leaf dependents.
Sourcepub fn mark_update_needed(&mut self, peer_id: NodeAddr)
pub fn mark_update_needed(&mut self, peer_id: NodeAddr)
Mark that a peer needs an update.
Sourcepub fn mark_all_updates_needed(
&mut self,
peer_ids: impl IntoIterator<Item = NodeAddr>,
)
pub fn mark_all_updates_needed( &mut self, peer_ids: impl IntoIterator<Item = NodeAddr>, )
Mark all peers as needing updates.
Sourcepub fn needs_update(&self, peer_id: &NodeAddr) -> bool
pub fn needs_update(&self, peer_id: &NodeAddr) -> bool
Check if a peer needs an update.
Sourcepub fn should_send_update(
&self,
peer_id: &NodeAddr,
current_time_ms: u64,
) -> bool
pub fn should_send_update( &self, peer_id: &NodeAddr, current_time_ms: u64, ) -> bool
Check if we should send an update to a peer (respecting debounce).
Sourcepub fn record_update_sent(&mut self, peer_id: NodeAddr, current_time_ms: u64)
pub fn record_update_sent(&mut self, peer_id: NodeAddr, current_time_ms: u64)
Record that we sent an update to a peer.
Sourcepub fn clear_pending_updates(&mut self)
pub fn clear_pending_updates(&mut self)
Clear all pending updates.
Sourcepub fn record_sent_filter(&mut self, peer_id: NodeAddr, filter: BloomFilter)
pub fn record_sent_filter(&mut self, peer_id: NodeAddr, filter: BloomFilter)
Record the outgoing filter that was sent to a peer.
Sourcepub fn remove_peer_state(&mut self, peer_id: &NodeAddr)
pub fn remove_peer_state(&mut self, peer_id: &NodeAddr)
Remove stored filter state for a peer that was removed.
Sourcepub fn mark_changed_peers(
&mut self,
exclude_from: &NodeAddr,
peer_addrs: &[NodeAddr],
peer_filters: &HashMap<NodeAddr, BloomFilter>,
)
pub fn mark_changed_peers( &mut self, exclude_from: &NodeAddr, peer_addrs: &[NodeAddr], peer_filters: &HashMap<NodeAddr, BloomFilter>, )
Mark only peers whose outgoing filter has actually changed.
Computes the outgoing filter for each peer and compares it against what was last sent. Only marks peers where the filter differs. This prevents cascading update loops in steady state.
Sourcepub fn compute_outgoing_filter(
&self,
exclude_peer: &NodeAddr,
peer_filters: &HashMap<NodeAddr, BloomFilter>,
) -> BloomFilter
pub fn compute_outgoing_filter( &self, exclude_peer: &NodeAddr, peer_filters: &HashMap<NodeAddr, BloomFilter>, ) -> BloomFilter
Compute the outgoing filter for a specific peer.
The filter includes:
- This node’s own ID
- All leaf dependents
- Entries from other peers’ inbound filters (excluding the destination peer)
The peer_filters map contains inbound filters from each peer.
The filter for exclude_peer is excluded to prevent routing loops.
Sourcepub fn base_filter(&self) -> BloomFilter
pub fn base_filter(&self) -> BloomFilter
Create a base filter containing just this node and its dependents.
Trait Implementations§
Source§impl Clone for BloomState
impl Clone for BloomState
Source§fn clone(&self) -> BloomState
fn clone(&self) -> BloomState
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for BloomState
impl RefUnwindSafe for BloomState
impl Send for BloomState
impl Sync for BloomState
impl Unpin for BloomState
impl UnsafeUnpin for BloomState
impl UnwindSafe for BloomState
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more