[][src]Struct gossip::GossipService

pub struct GossipService<T> { /* fields omitted */ }

The gossip service

Implementations

impl<T> GossipService<T> where
    T: UpdateHandler + 'static + Send
[src]

pub fn new(
    address: SocketAddr,
    peer_sampling_config: PeerSamplingConfig,
    gossip_config: GossipConfig
) -> GossipService<T>
[src]

Creates a new gossiping service

Arguments

  • address - Socket address of the node
  • peer_sampling_config - Configuration for peer sampling, see PeerSamplingConfig
  • gossip_config - Configuration for gossiping, see GossipConfig

pub fn new_with_defaults(address: SocketAddr) -> Self[src]

Create a gossip service with default configurations

Arguments

  • address - Socket address of the node

pub fn address(&self) -> &SocketAddr[src]

Returns the node address

pub fn peers(&self) -> Vec<Peer>[src]

Returns a list of the node's peer

pub fn start(
    &mut self,
    peer_sampling_init: Box<dyn FnOnce() -> Option<Vec<Peer>>>,
    update_handler: Box<T>
) -> Result<(), Box<dyn Error>>
[src]

Starts the gossip protocol and related threads

Arguments

  • peer_sampling_init - Closure for retrieving the address of the first peer to contact
  • update_handler - Application callback for receiving new updates

pub fn submit(&self, bytes: Vec<u8>) -> Result<(), Box<dyn Error>>[src]

Submits a message for broadcast by the gossip protocol

Arguments

  • bytes - Content of the message

pub fn is_active(&self, bytes: Vec<u8>) -> bool[src]

pub fn is_expired(&self, bytes: Vec<u8>) -> bool[src]

pub fn shutdown(&mut self) -> Result<(), Box<dyn Error>>[src]

Terminates the gossip protocol and related threads

Auto Trait Implementations

impl<T> !RefUnwindSafe for GossipService<T>[src]

impl<T> Send for GossipService<T> where
    T: Send
[src]

impl<T> Sync for GossipService<T> where
    T: Send
[src]

impl<T> Unpin for GossipService<T>[src]

impl<T> !UnwindSafe for GossipService<T>[src]

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

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