pub trait SyncProtocolExecutor {
type Config: Send;
type ResponderInit: Send;
type Stats: Send + Default;
// Required methods
fn run_initiator<'life0, 'life1, 'async_trait, T>(
transport: &'life0 mut T,
store: &'life1 Store,
context_id: ContextId,
identity: PublicKey,
config: Self::Config,
) -> Pin<Box<dyn Future<Output = Result<Self::Stats>> + 'async_trait>>
where T: 'async_trait + SyncTransport,
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn run_responder<'life0, 'life1, 'async_trait, T>(
transport: &'life0 mut T,
store: &'life1 Store,
context_id: ContextId,
identity: PublicKey,
first_request: Self::ResponderInit,
) -> Pin<Box<dyn Future<Output = Result<()>> + 'async_trait>>
where T: 'async_trait + SyncTransport,
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
}Expand description
Trait for sync protocol implementations.
Each sync protocol (HashComparison, Snapshot, LevelWise, etc.) implements this trait. The protocol logic is generic over:
T: SyncTransport- the transport layer (production streams or simulation channels)Store- the storage backend (RocksDB or InMemoryDB)
This enables the same protocol code to run in both production and simulation.
Note: Uses ?Send because RuntimeEnv (used for storage access) contains Rc
which is not Send. Callers must not spawn these futures across threads.
Required Associated Types§
Sourcetype Config: Send
type Config: Send
Protocol-specific configuration for the initiator.
For example, HashComparison needs the remote root hash.
Sourcetype ResponderInit: Send
type ResponderInit: Send
Data extracted from the first request for responder dispatch.
The manager parses the first InitPayload and constructs this type
to pass to run_responder. This is necessary because the manager
consumes the first message for routing, so the protocol cannot
recv() it again.
For example:
- HashComparison needs
{ node_id, max_depth }fromTreeNodeRequest - LevelWise needs
{ level, parent_ids }fromLevelWiseRequest
Required Methods§
Sourcefn run_initiator<'life0, 'life1, 'async_trait, T>(
transport: &'life0 mut T,
store: &'life1 Store,
context_id: ContextId,
identity: PublicKey,
config: Self::Config,
) -> Pin<Box<dyn Future<Output = Result<Self::Stats>> + 'async_trait>>where
T: 'async_trait + SyncTransport,
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn run_initiator<'life0, 'life1, 'async_trait, T>(
transport: &'life0 mut T,
store: &'life1 Store,
context_id: ContextId,
identity: PublicKey,
config: Self::Config,
) -> Pin<Box<dyn Future<Output = Result<Self::Stats>> + 'async_trait>>where
T: 'async_trait + SyncTransport,
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Run the initiator (pulling) side of the protocol.
The initiator requests data from the responder and applies it locally.
§Arguments
transport- The transport for sending/receiving messagesstore- The local storage (works with both RocksDB and InMemoryDB)context_id- The context being syncedidentity- Our identity for this contextconfig- Protocol-specific configuration
§Returns
Protocol-specific statistics on success.
Sourcefn run_responder<'life0, 'life1, 'async_trait, T>(
transport: &'life0 mut T,
store: &'life1 Store,
context_id: ContextId,
identity: PublicKey,
first_request: Self::ResponderInit,
) -> Pin<Box<dyn Future<Output = Result<()>> + 'async_trait>>where
T: 'async_trait + SyncTransport,
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn run_responder<'life0, 'life1, 'async_trait, T>(
transport: &'life0 mut T,
store: &'life1 Store,
context_id: ContextId,
identity: PublicKey,
first_request: Self::ResponderInit,
) -> Pin<Box<dyn Future<Output = Result<()>> + 'async_trait>>where
T: 'async_trait + SyncTransport,
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Run the responder side of the protocol.
The responder answers requests from the initiator. The first request’s
data is passed via first_request because the manager has already
consumed the first message for routing.
§Arguments
transport- The transport for sending/receiving messagesstore- The local storagecontext_id- The context being syncedidentity- Our identity for this contextfirst_request- Data from the firstInitPayload, extracted by the manager
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.