pub struct GossipEngine<B: BlockT> { /* private fields */ }
Expand description
Wraps around an implementation of the Network
trait and provides gossiping capabilities on
top of it.
Implementations§
source§impl<B: BlockT> GossipEngine<B>
impl<B: BlockT> GossipEngine<B>
sourcepub fn new<N, S>(
network: N,
sync: S,
notification_service: Box<dyn NotificationService>,
protocol: impl Into<ProtocolName>,
validator: Arc<dyn Validator<B>>,
metrics_registry: Option<&Registry>,
) -> Self
pub fn new<N, S>( network: N, sync: S, notification_service: Box<dyn NotificationService>, protocol: impl Into<ProtocolName>, validator: Arc<dyn Validator<B>>, metrics_registry: Option<&Registry>, ) -> Self
Create a new instance.
pub fn report(&self, who: PeerId, reputation: ReputationChange)
sourcepub fn register_gossip_message(&mut self, topic: B::Hash, message: Vec<u8>)
pub fn register_gossip_message(&mut self, topic: B::Hash, message: Vec<u8>)
Registers a message without propagating it to any peers. The message becomes available to new peers or when the service is asked to gossip the message’s topic. No validation is performed on the message, if the message is already expired it should be dropped on the next garbage collection.
sourcepub fn broadcast_topic(&mut self, topic: B::Hash, force: bool)
pub fn broadcast_topic(&mut self, topic: B::Hash, force: bool)
Broadcast all messages with given topic.
sourcepub fn messages_for(&mut self, topic: B::Hash) -> Receiver<TopicNotification>
pub fn messages_for(&mut self, topic: B::Hash) -> Receiver<TopicNotification>
Get data of valid, incoming messages for a topic (but might have expired meanwhile).
sourcepub fn send_topic(&mut self, who: &PeerId, topic: B::Hash, force: bool)
pub fn send_topic(&mut self, who: &PeerId, topic: B::Hash, force: bool)
Send all messages with given topic to a peer.
sourcepub fn gossip_message(&mut self, topic: B::Hash, message: Vec<u8>, force: bool)
pub fn gossip_message(&mut self, topic: B::Hash, message: Vec<u8>, force: bool)
Multicast a message to all peers.
sourcepub fn send_message(&mut self, who: Vec<PeerId>, data: Vec<u8>)
pub fn send_message(&mut self, who: Vec<PeerId>, data: Vec<u8>)
Send addressed message to the given peers. The message is not kept or multicast later on.
sourcepub fn announce(&self, block: B::Hash, associated_data: Option<Vec<u8>>)
pub fn announce(&self, block: B::Hash, associated_data: Option<Vec<u8>>)
Notify everyone we’re connected to that we have the given block.
Note: this method isn’t strictly related to gossiping and should eventually be moved somewhere else.
sourcepub fn take_notification_service(self) -> Box<dyn NotificationService>
pub fn take_notification_service(self) -> Box<dyn NotificationService>
Consume GossipEngine
and return the notification service.
Trait Implementations§
source§impl<B: BlockT> FusedFuture for GossipEngine<B>
impl<B: BlockT> FusedFuture for GossipEngine<B>
source§fn is_terminated(&self) -> bool
fn is_terminated(&self) -> bool
true
if the underlying future should no longer be polled.source§impl<B: BlockT> Future for GossipEngine<B>
impl<B: BlockT> Future for GossipEngine<B>
impl<B: BlockT> Unpin for GossipEngine<B>
Auto Trait Implementations§
impl<B> Freeze for GossipEngine<B>
impl<B> !RefUnwindSafe for GossipEngine<B>
impl<B> Send for GossipEngine<B>
impl<B> !Sync for GossipEngine<B>
impl<B> !UnwindSafe for GossipEngine<B>
Blanket Implementations§
source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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
source§impl<T> CheckedConversion for T
impl<T> CheckedConversion for T
source§impl<T> FutureExt for T
impl<T> FutureExt for T
source§fn map<U, F>(self, f: F) -> Map<Self, F>
fn map<U, F>(self, f: F) -> Map<Self, F>
source§fn map_into<U>(self) -> MapInto<Self, U>
fn map_into<U>(self) -> MapInto<Self, U>
source§fn then<Fut, F>(self, f: F) -> Then<Self, Fut, F>
fn then<Fut, F>(self, f: F) -> Then<Self, Fut, F>
f
. Read moresource§fn left_future<B>(self) -> Either<Self, B>
fn left_future<B>(self) -> Either<Self, B>
source§fn right_future<A>(self) -> Either<A, Self>
fn right_future<A>(self) -> Either<A, Self>
source§fn into_stream(self) -> IntoStream<Self>where
Self: Sized,
fn into_stream(self) -> IntoStream<Self>where
Self: Sized,
source§fn flatten(self) -> Flatten<Self>
fn flatten(self) -> Flatten<Self>
source§fn flatten_stream(self) -> FlattenStream<Self>
fn flatten_stream(self) -> FlattenStream<Self>
source§fn fuse(self) -> Fuse<Self>where
Self: Sized,
fn fuse(self) -> Fuse<Self>where
Self: Sized,
poll
will never again be called once it has
completed. This method can be used to turn any Future
into a
FusedFuture
. Read moresource§fn inspect<F>(self, f: F) -> Inspect<Self, F>
fn inspect<F>(self, f: F) -> Inspect<Self, F>
source§fn catch_unwind(self) -> CatchUnwind<Self>where
Self: Sized + UnwindSafe,
fn catch_unwind(self) -> CatchUnwind<Self>where
Self: Sized + UnwindSafe,
source§fn remote_handle(self) -> (Remote<Self>, RemoteHandle<Self::Output>)where
Self: Sized,
fn remote_handle(self) -> (Remote<Self>, RemoteHandle<Self::Output>)where
Self: Sized,
()
on completion and sends
its output to another future on a separate task. Read moresource§fn boxed<'a>(self) -> Pin<Box<dyn Future<Output = Self::Output> + Send + 'a>>
fn boxed<'a>(self) -> Pin<Box<dyn Future<Output = Self::Output> + Send + 'a>>
source§fn boxed_local<'a>(self) -> Pin<Box<dyn Future<Output = Self::Output> + 'a>>where
Self: Sized + 'a,
fn boxed_local<'a>(self) -> Pin<Box<dyn Future<Output = Self::Output> + 'a>>where
Self: Sized + 'a,
source§fn unit_error(self) -> UnitError<Self>where
Self: Sized,
fn unit_error(self) -> UnitError<Self>where
Self: Sized,
Future<Output = T>
into a
TryFuture<Ok = T, Error = ()
>.source§fn never_error(self) -> NeverError<Self>where
Self: Sized,
fn never_error(self) -> NeverError<Self>where
Self: Sized,
Future<Output = T>
into a
TryFuture<Ok = T, Error = Never
>.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 moresource§impl<F> IntoFuture for Fwhere
F: Future,
impl<F> IntoFuture for Fwhere
F: Future,
source§type IntoFuture = F
type IntoFuture = F
source§fn into_future(self) -> <F as IntoFuture>::IntoFuture
fn into_future(self) -> <F as IntoFuture>::IntoFuture
source§impl<T, Outer> IsWrappedBy<Outer> for T
impl<T, Outer> IsWrappedBy<Outer> for T
source§impl<T> Pointable for T
impl<T> Pointable for T
source§impl<T> SaturatedConversion for T
impl<T> SaturatedConversion for T
source§fn saturated_from<T>(t: T) -> Selfwhere
Self: UniqueSaturatedFrom<T>,
fn saturated_from<T>(t: T) -> Selfwhere
Self: UniqueSaturatedFrom<T>,
source§fn saturated_into<T>(self) -> Twhere
Self: UniqueSaturatedInto<T>,
fn saturated_into<T>(self) -> Twhere
Self: UniqueSaturatedInto<T>,
T
. Read moresource§impl<S, T> UncheckedInto<T> for Swhere
T: UncheckedFrom<S>,
impl<S, T> UncheckedInto<T> for Swhere
T: UncheckedFrom<S>,
source§fn unchecked_into(self) -> T
fn unchecked_into(self) -> T
unchecked_from
.source§impl<T, S> UniqueSaturatedInto<T> for S
impl<T, S> UniqueSaturatedInto<T> for S
source§fn unique_saturated_into(self) -> T
fn unique_saturated_into(self) -> T
T
.