Skip to main content

BloomState

Struct BloomState 

Source
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

Source

pub fn new(own_node_addr: NodeAddr) -> Self

Create new Bloom state for a node.

Source

pub fn leaf_only(own_node_addr: NodeAddr) -> Self

Create state for a leaf-only node.

Source

pub fn own_node_addr(&self) -> &NodeAddr

Get the node’s own ID.

Source

pub fn is_leaf_only(&self) -> bool

Check if this is a leaf-only node.

Source

pub fn sequence(&self) -> u64

Get the current sequence number.

Source

pub fn next_sequence(&mut self) -> u64

Increment and return the next sequence number.

Source

pub fn update_debounce_ms(&self) -> u64

Get the update debounce interval in milliseconds.

Source

pub fn set_update_debounce_ms(&mut self, ms: u64)

Set the update debounce interval.

Source

pub fn add_leaf_dependent(&mut self, node_addr: NodeAddr)

Add a leaf dependent that we’ll include in our filter.

Source

pub fn remove_leaf_dependent(&mut self, node_addr: &NodeAddr) -> bool

Remove a leaf dependent.

Source

pub fn leaf_dependents(&self) -> &HashSet<NodeAddr>

Get the set of leaf dependents.

Source

pub fn leaf_dependent_count(&self) -> usize

Number of leaf dependents.

Source

pub fn mark_update_needed(&mut self, peer_id: NodeAddr)

Mark that a peer needs an update.

Source

pub fn mark_all_updates_needed( &mut self, peer_ids: impl IntoIterator<Item = NodeAddr>, )

Mark all peers as needing updates.

Source

pub fn needs_update(&self, peer_id: &NodeAddr) -> bool

Check if a peer needs an update.

Source

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).

Source

pub fn record_update_sent(&mut self, peer_id: NodeAddr, current_time_ms: u64)

Record that we sent an update to a peer.

Source

pub fn clear_pending_updates(&mut self)

Clear all pending updates.

Source

pub fn record_sent_filter(&mut self, peer_id: NodeAddr, filter: BloomFilter)

Record the outgoing filter that was sent to a peer.

Source

pub fn remove_peer_state(&mut self, peer_id: &NodeAddr)

Remove stored filter state for a peer that was removed.

Source

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.

Source

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.

Source

pub fn base_filter(&self) -> BloomFilter

Create a base filter containing just this node and its dependents.

Trait Implementations§

Source§

impl Clone for BloomState

Source§

fn clone(&self) -> BloomState

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for BloomState

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more