pub struct SyncForwarder { /* private fields */ }Expand description
Sync message forwarder for multi-hop mesh networks
The forwarder tracks which batches have been forwarded to prevent loops and determines the appropriate forwarding targets based on sync direction.
Implementations§
Source§impl SyncForwarder
impl SyncForwarder
Sourcepub fn new(local_node_id: PublicKey) -> SyncForwarder
pub fn new(local_node_id: PublicKey) -> SyncForwarder
Create a new forwarder
Sourcepub fn set_parent(&self, parent_id: Option<PublicKey>)
pub fn set_parent(&self, parent_id: Option<PublicKey>)
Set the parent node for upward forwarding
Sourcepub fn remove_child(&self, child_id: &PublicKey)
pub fn remove_child(&self, child_id: &PublicKey)
Remove a child node
Sourcepub fn was_forwarded(&self, batch_id: u64) -> bool
pub fn was_forwarded(&self, batch_id: u64) -> bool
Check if a batch has already been forwarded
Sourcepub fn mark_forwarded(&self, batch_id: u64)
pub fn mark_forwarded(&self, batch_id: u64)
Mark a batch as forwarded (for deduplication)
Sourcepub fn forward_targets(
&self,
batch: &SyncBatch,
source_peer: PublicKey,
connected_peers: &[PublicKey],
) -> Option<Vec<PublicKey>>
pub fn forward_targets( &self, batch: &SyncBatch, source_peer: PublicKey, connected_peers: &[PublicKey], ) -> Option<Vec<PublicKey>>
Determine forwarding targets for a received batch
Returns None if:
- Batch was already forwarded (duplicate)
- Batch TTL is 0 (expired)
Returns Some(empty vec) if no forwarding needed. Returns Some(targets) with the peers to forward to.
Sourcepub fn prepare_for_forward(&self, batch: &SyncBatch) -> Option<SyncBatch>
pub fn prepare_for_forward(&self, batch: &SyncBatch) -> Option<SyncBatch>
Prepare a batch for forwarding by decrementing TTL
Returns a cloned batch with decremented TTL, or None if TTL would be 0.
Auto Trait Implementations§
impl !Freeze for SyncForwarder
impl RefUnwindSafe for SyncForwarder
impl Send for SyncForwarder
impl Sync for SyncForwarder
impl Unpin for SyncForwarder
impl UnsafeUnpin for SyncForwarder
impl UnwindSafe for SyncForwarder
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
Mutably borrows from an owned value. Read more
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>
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 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>
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