Skip to main content

GossipSyncEngine

Struct GossipSyncEngine 

Source
pub struct GossipSyncEngine { /* private fields */ }
Expand description

Incremental sync engine.

Maintains a per-peer cursor (last seen sequence number) so that each gossip round only exchanges new assets. Received assets are admitted into a QuarantineStore; the caller is responsible for driving the validate → promote lifecycle.

Implementations§

Source§

impl GossipSyncEngine

Source

pub fn new(local_peer_id: impl Into<String>) -> Self

Source

pub fn publish_local(&self, asset: NetworkAsset) -> u64

Publish a local asset, incrementing the sequence counter. Returns the sequence number assigned to this asset.

Source

pub fn build_publish_request(&self, since_cursor: u64) -> PublishRequest

Build a PublishRequest containing all local assets with sequence > since_cursor. Use since_cursor = 0 to send everything.

Source

pub fn receive_publish(&self, request: &PublishRequest) -> SyncAudit

Process a PublishRequest received from a remote peer.

Each asset is admitted to the QuarantineStore as Pending. Duplicates (already in quarantine) are counted as skipped. Returns a SyncAudit summarising what happened.

Source

pub fn build_fetch_query( &self, peer_id: &str, signals: Vec<String>, ) -> FetchQuery

Build a FetchQuery for a remote peer, supplying the last-seen cursor so only delta assets are returned.

Source

pub fn receive_fetch_response( &self, peer_id: &str, response: &FetchResponse, ) -> SyncAudit

Process a FetchResponse received from a remote peer.

Same quarantine semantics as receive_publish.

Source

pub fn validate_and_promote<F>(&self, asset_id: &str, validator: F) -> bool

Drive the validate → promote step for a single asset.

validator is a closure receiving the asset and returning Ok(true) when it passes. On success the asset moves to Validated; on error it moves to Failed and the error message is stored.

Source

pub fn is_asset_selectable(&self, asset_id: &str) -> bool

Returns true when asset_id is in the quarantine store and has been validated. Unvalidated or unknown assets always return false — ensuring the failure-closed safety guarantee.

Source

pub fn pending_entries(&self) -> Vec<QuarantineEntry>

All pending (not yet validated) quarantine entries.

Source

pub fn stats(&self) -> SyncStats

Current statistics snapshot.

Source

pub fn peer_cursor(&self, peer_id: &str) -> u64

Last seen sequence for peer_id.

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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> Same for T

Source§

type Output = T

Should always be Self
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.