pub struct GossipSyncEngine { /* private fields */ }evolution-network-experimental only.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
impl GossipSyncEngine
pub fn new(local_peer_id: impl Into<String>) -> GossipSyncEngine
Sourcepub fn publish_local(&self, asset: NetworkAsset) -> u64
pub fn publish_local(&self, asset: NetworkAsset) -> u64
Publish a local asset, incrementing the sequence counter. Returns the sequence number assigned to this asset.
Sourcepub fn build_publish_request(&self, since_cursor: u64) -> PublishRequest
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.
Sourcepub fn receive_publish(&self, request: &PublishRequest) -> SyncAudit
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.
Sourcepub fn build_fetch_query(
&self,
peer_id: &str,
signals: Vec<String>,
) -> FetchQuery
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.
Sourcepub fn receive_fetch_response(
&self,
peer_id: &str,
response: &FetchResponse,
) -> SyncAudit
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.
Sourcepub fn validate_and_promote<F>(&self, asset_id: &str, validator: F) -> bool
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.
Sourcepub fn is_asset_selectable(&self, asset_id: &str) -> bool
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.
Sourcepub fn pending_entries(&self) -> Vec<QuarantineEntry>
pub fn pending_entries(&self) -> Vec<QuarantineEntry>
All pending (not yet validated) quarantine entries.
Sourcepub fn peer_cursor(&self, peer_id: &str) -> u64
pub fn peer_cursor(&self, peer_id: &str) -> u64
Last seen sequence for peer_id.
Auto Trait Implementations§
impl !Freeze for GossipSyncEngine
impl RefUnwindSafe for GossipSyncEngine
impl Send for GossipSyncEngine
impl Sync for GossipSyncEngine
impl Unpin for GossipSyncEngine
impl UnsafeUnpin for GossipSyncEngine
impl UnwindSafe for GossipSyncEngine
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> 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