pub struct TopicLogSync<T, S, L, E> {
pub topic: T,
pub store: S,
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 TopicStore 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§
§topic: T§store: S§event_tx: Sender<TopicLogSyncEvent<E>>§live_mode_rx: Option<Receiver<ToSync<Operation<E>>>>§buffer_capacity: usize§_phantom: PhantomData<L>Implementations§
Source§impl<T, S, L, E> TopicLogSync<T, S, L, E>where
T: Eq + StdHash + Serialize + for<'a> Deserialize<'a>,
S: LogStore<Operation<E>, VerifyingKey, L, SeqNum, Hash> + TopicStore<T, VerifyingKey, L> + Clone + Send + 'static,
L: LogId,
E: Extensions,
impl<T, S, L, E> TopicLogSync<T, S, L, E>where
T: Eq + StdHash + Serialize + for<'a> Deserialize<'a>,
S: LogStore<Operation<E>, VerifyingKey, L, SeqNum, Hash> + TopicStore<T, VerifyingKey, L> + Clone + Send + 'static,
L: LogId,
E: Extensions,
Sourcepub fn new(
topic: T,
store: S,
live_mode_rx: Option<Receiver<ToSync<Operation<E>>>>,
event_tx: Sender<TopicLogSyncEvent<E>>,
) -> Self
pub fn new( topic: T, store: S, 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 TopicStore implementation
which associates the to-be-synced logs with a given topic.
Sourcepub fn new_with_capacity(
topic: T,
store: S,
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, 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.
Trait Implementations§
Source§impl<T, S, L, E> Protocol for TopicLogSync<T, S, L, E>where
T: Debug + Eq + StdHash + Serialize + for<'a> Deserialize<'a> + Send + 'static,
S: LogStore<Operation<E>, VerifyingKey, L, SeqNum, Hash> + TopicStore<T, VerifyingKey, L> + Clone + Send + 'static,
L: LogId + Debug + Send + 'static,
E: Extensions + Send + 'static,
impl<T, S, L, E> Protocol for TopicLogSync<T, S, L, E>where
T: Debug + Eq + StdHash + Serialize + for<'a> Deserialize<'a> + Send + 'static,
S: LogStore<Operation<E>, VerifyingKey, L, SeqNum, Hash> + TopicStore<T, VerifyingKey, L> + Clone + Send + 'static,
L: LogId + Debug + Send + 'static,
E: Extensions + Send + 'static,
type Error = TopicLogSyncError
type Message = TopicLogSyncMessage<L, E>
type Output = ()
async fn run( self, sink: &mut (impl Sink<Self::Message, Error = impl Debug> + Unpin), stream: &mut (impl Stream<Item = Result<Self::Message, impl Debug>> + Unpin), ) -> Result<Self::Output, Self::Error>
Auto Trait Implementations§
impl<T, S, L, E> !RefUnwindSafe for TopicLogSync<T, S, L, E>
impl<T, S, L, E> !UnwindSafe for TopicLogSync<T, S, L, E>
impl<T, S, L, E> Freeze for TopicLogSync<T, S, L, E>
impl<T, S, L, E> Send for TopicLogSync<T, S, L, E>
impl<T, S, L, E> Sync for TopicLogSync<T, S, L, E>
impl<T, S, L, E> Unpin for TopicLogSync<T, S, L, E>
impl<T, S, L, E> UnsafeUnpin for TopicLogSync<T, S, L, E>where
T: UnsafeUnpin,
S: UnsafeUnpin,
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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