pub struct TopicLogSync<T, S, M, L, E> {
pub store: S,
pub topic_map: M,
pub topic: T,
pub event_tx: Sender<TopicLogSyncEvent<E>>,
pub live_mode_rx: Option<Receiver<ToSync<Operation<E>>>>,
pub buffer_capacity: usize,
pub _phantom: PhantomData<L>,
}Expand description
Protocol for synchronizing logs which are associated with a generic T topic.
The mapping of T to a set of logs is handled on the application layer using an implementation
of the TopicMap trait.
After sync is complete peers optionally enter “live-mode” where concurrently received and future messages will be sent directly to the application layer and forwarded to any concurrently running sync sessions. As we may receive messages from many sync sessions concurrently, messages forwarded to a sync session in live-mode are de-duplicated in order to avoid flooding the network with redundant data.
It is assumed that the T topic has been negotiated between parties prior to initiating this sync protocol.
Fields§
§store: S§topic_map: M§topic: T§event_tx: Sender<TopicLogSyncEvent<E>>§live_mode_rx: Option<Receiver<ToSync<Operation<E>>>>§buffer_capacity: usize§_phantom: PhantomData<L>Implementations§
Source§impl<T, S, M, L, E> TopicLogSync<T, S, M, L, E>where
T: Eq + StdHash + Serialize + for<'a> Deserialize<'a>,
S: LogStore<L, E> + OperationStore<L, E>,
M: TopicMap<T, Logs<L>>,
L: LogId + for<'de> Deserialize<'de> + Serialize,
E: Extensions,
impl<T, S, M, L, E> TopicLogSync<T, S, M, L, E>where
T: Eq + StdHash + Serialize + for<'a> Deserialize<'a>,
S: LogStore<L, E> + OperationStore<L, E>,
M: TopicMap<T, Logs<L>>,
L: LogId + for<'de> Deserialize<'de> + Serialize,
E: Extensions,
Sourcepub fn new(
topic: T,
store: S,
topic_map: M,
live_mode_rx: Option<Receiver<ToSync<Operation<E>>>>,
event_tx: Sender<TopicLogSyncEvent<E>>,
) -> Self
pub fn new( topic: T, store: S, topic_map: M, live_mode_rx: Option<Receiver<ToSync<Operation<E>>>>, event_tx: Sender<TopicLogSyncEvent<E>>, ) -> Self
Returns a new sync protocol instance, configured with a store and TopicMap implementation
which associates the to-be-synced logs with a given topic.
Sourcepub fn new_with_capacity(
topic: T,
store: S,
topic_map: M,
live_mode_rx: Option<Receiver<ToSync<Operation<E>>>>,
event_tx: Sender<TopicLogSyncEvent<E>>,
buffer_capacity: usize,
) -> Self
pub fn new_with_capacity( topic: T, store: S, topic_map: M, live_mode_rx: Option<Receiver<ToSync<Operation<E>>>>, event_tx: Sender<TopicLogSyncEvent<E>>, buffer_capacity: usize, ) -> Self
Instantiates a sync protocol with custom buffer capacity.