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