Trait hotshot_types::traits::network::ConnectedNetwork
source · pub trait ConnectedNetwork<K: SignatureKey + 'static>: Clone + Send + Sync + 'static {
Show 14 methods
// Required methods
fn pause(&self);
fn resume(&self);
fn wait_for_ready<'life0, 'async_trait>(
&'life0 self
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn shut_down<'a, 'b>(&'a self) -> BoxSyncFuture<'b, ()>
where Self: 'b,
'a: 'b;
fn broadcast_message<'life0, 'async_trait>(
&'life0 self,
message: Vec<u8>,
topic: Topic,
broadcast_delay: BroadcastDelay
) -> Pin<Box<dyn Future<Output = Result<(), NetworkError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn da_broadcast_message<'life0, 'async_trait>(
&'life0 self,
message: Vec<u8>,
recipients: BTreeSet<K>,
broadcast_delay: BroadcastDelay
) -> Pin<Box<dyn Future<Output = Result<(), NetworkError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn direct_message<'life0, 'async_trait>(
&'life0 self,
message: Vec<u8>,
recipient: K
) -> Pin<Box<dyn Future<Output = Result<(), NetworkError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn recv_message<'life0, 'async_trait>(
&'life0 self
) -> Pin<Box<dyn Future<Output = Result<Vec<u8>, NetworkError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
// Provided methods
fn vid_broadcast_message<'life0, 'async_trait>(
&'life0 self,
messages: HashMap<K, Vec<u8>>
) -> Pin<Box<dyn Future<Output = Result<(), NetworkError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait { ... }
fn request_data<'life0, 'life1, 'async_trait, TYPES>(
&'life0 self,
_request: Vec<u8>,
_recipient: &'life1 K
) -> Pin<Box<dyn Future<Output = Result<Vec<u8>, NetworkError>> + Send + 'async_trait>>
where TYPES: 'async_trait + NodeType,
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait { ... }
fn spawn_request_receiver_task<'life0, 'async_trait>(
&'life0 self
) -> Pin<Box<dyn Future<Output = Option<Receiver<(Vec<u8>, NetworkMsgResponseChannel<Vec<u8>>)>>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait { ... }
fn queue_node_lookup(
&self,
_view_number: ViewNumber,
_pk: K
) -> Result<(), TrySendError<Option<(ViewNumber, K)>>> { ... }
fn update_view<'a, 'life0, 'async_trait, TYPES>(
&'a self,
_view: u64,
_membership: &'life0 TYPES::Membership
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where TYPES: NodeType<SignatureKey = K> + 'a + 'async_trait,
Self: 'async_trait,
'a: 'async_trait,
'life0: 'async_trait { ... }
fn is_primary_down(&self) -> bool { ... }
}
Expand description
represents a networking implmentration exposes low level API for interacting with a network intended to be implemented for libp2p, the centralized server, and memory network
Required Methods§
sourcefn wait_for_ready<'life0, 'async_trait>(
&'life0 self
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn wait_for_ready<'life0, 'async_trait>(
&'life0 self
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Blocks until the network is successfully initialized
sourcefn shut_down<'a, 'b>(&'a self) -> BoxSyncFuture<'b, ()>where
Self: 'b,
'a: 'b,
fn shut_down<'a, 'b>(&'a self) -> BoxSyncFuture<'b, ()>where
Self: 'b,
'a: 'b,
Blocks until the network is shut down
sourcefn broadcast_message<'life0, 'async_trait>(
&'life0 self,
message: Vec<u8>,
topic: Topic,
broadcast_delay: BroadcastDelay
) -> Pin<Box<dyn Future<Output = Result<(), NetworkError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn broadcast_message<'life0, 'async_trait>(
&'life0 self,
message: Vec<u8>,
topic: Topic,
broadcast_delay: BroadcastDelay
) -> Pin<Box<dyn Future<Output = Result<(), NetworkError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
broadcast message to some subset of nodes blocking
sourcefn da_broadcast_message<'life0, 'async_trait>(
&'life0 self,
message: Vec<u8>,
recipients: BTreeSet<K>,
broadcast_delay: BroadcastDelay
) -> Pin<Box<dyn Future<Output = Result<(), NetworkError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn da_broadcast_message<'life0, 'async_trait>(
&'life0 self,
message: Vec<u8>,
recipients: BTreeSet<K>,
broadcast_delay: BroadcastDelay
) -> Pin<Box<dyn Future<Output = Result<(), NetworkError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
broadcast a message only to a DA committee blocking
Provided Methods§
sourcefn vid_broadcast_message<'life0, 'async_trait>(
&'life0 self,
messages: HashMap<K, Vec<u8>>
) -> Pin<Box<dyn Future<Output = Result<(), NetworkError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn vid_broadcast_message<'life0, 'async_trait>(
&'life0 self,
messages: HashMap<K, Vec<u8>>
) -> Pin<Box<dyn Future<Output = Result<(), NetworkError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
send messages with vid shares to its recipients blocking
sourcefn request_data<'life0, 'life1, 'async_trait, TYPES>(
&'life0 self,
_request: Vec<u8>,
_recipient: &'life1 K
) -> Pin<Box<dyn Future<Output = Result<Vec<u8>, NetworkError>> + Send + 'async_trait>>where
TYPES: 'async_trait + NodeType,
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn request_data<'life0, 'life1, 'async_trait, TYPES>(
&'life0 self,
_request: Vec<u8>,
_recipient: &'life1 K
) -> Pin<Box<dyn Future<Output = Result<Vec<u8>, NetworkError>> + Send + 'async_trait>>where
TYPES: 'async_trait + NodeType,
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Ask request the network for some data. Returns the request ID for that data, The ID returned can be used for cancelling the request
sourcefn spawn_request_receiver_task<'life0, 'async_trait>(
&'life0 self
) -> Pin<Box<dyn Future<Output = Option<Receiver<(Vec<u8>, NetworkMsgResponseChannel<Vec<u8>>)>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn spawn_request_receiver_task<'life0, 'async_trait>(
&'life0 self
) -> Pin<Box<dyn Future<Output = Option<Receiver<(Vec<u8>, NetworkMsgResponseChannel<Vec<u8>>)>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Spawn a request task in the given network layer. If it supports Request and responses it will return the receiving end of a channel. Requests the network receives will be sent over this channel along with a return channel to send the response back to.
Returns `None`` if network does not support handling requests
sourcefn queue_node_lookup(
&self,
_view_number: ViewNumber,
_pk: K
) -> Result<(), TrySendError<Option<(ViewNumber, K)>>>
fn queue_node_lookup( &self, _view_number: ViewNumber, _pk: K ) -> Result<(), TrySendError<Option<(ViewNumber, K)>>>
sourcefn update_view<'a, 'life0, 'async_trait, TYPES>(
&'a self,
_view: u64,
_membership: &'life0 TYPES::Membership
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
TYPES: NodeType<SignatureKey = K> + 'a + 'async_trait,
Self: 'async_trait,
'a: 'async_trait,
'life0: 'async_trait,
fn update_view<'a, 'life0, 'async_trait, TYPES>(
&'a self,
_view: u64,
_membership: &'life0 TYPES::Membership
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
TYPES: NodeType<SignatureKey = K> + 'a + 'async_trait,
Self: 'async_trait,
'a: 'async_trait,
'life0: 'async_trait,
Update view can be used for any reason, but mostly it’s for canceling tasks, and looking up the address of the leader of a future view.
sourcefn is_primary_down(&self) -> bool
fn is_primary_down(&self) -> bool
Is primary network down? Makes sense only for combined network