Skip to main content

TopicLogSync

Struct TopicLogSync 

Source
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,

Source

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.

Source

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: Debug, S: Debug, L: Debug, E: Debug> Debug for TopicLogSync<T, S, L, E>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
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,

Source§

type Error = TopicLogSyncError

Source§

type Message = TopicLogSyncMessage<L, E>

Source§

type Output = ()

Source§

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>
where T: Freeze, S: Freeze,

§

impl<T, S, L, E> Send for TopicLogSync<T, S, L, E>
where T: Send, S: Send, L: Send, E: Send,

§

impl<T, S, L, E> Sync for TopicLogSync<T, S, L, E>
where T: Sync, S: Sync, L: Sync, E: Send,

§

impl<T, S, L, E> Unpin for TopicLogSync<T, S, L, E>
where T: Unpin, S: Unpin, L: Unpin,

§

impl<T, S, L, E> UnsafeUnpin for TopicLogSync<T, S, L, E>
where T: UnsafeUnpin, S: UnsafeUnpin,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more