Trait chain_network::core::server::Node
source · pub trait Node: Send + Sync + 'static {
type BlockService: BlockService + Send + Sync;
type FragmentService: FragmentService + Send + Sync;
type GossipService: GossipService + Send + Sync;
// Required methods
fn handshake<'life0, 'life1, 'async_trait>(
&'life0 self,
peer: Peer,
nonce: &'life1 [u8]
) -> Pin<Box<dyn Future<Output = Result<HandshakeResponse, Error>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn client_auth<'life0, 'async_trait>(
&'life0 self,
peer: Peer,
auth: AuthenticatedNodeId
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn block_service(&self) -> Option<&Self::BlockService>;
fn fragment_service(&self) -> Option<&Self::FragmentService>;
fn gossip_service(&self) -> Option<&Self::GossipService>;
}
Expand description
Interface to application logic of the blockchain node server.
An implementation of a blockchain node implements this trait to serve the network protocols using node’s subsystems such as block storage and fragment processor.
Required Associated Types§
sourcetype BlockService: BlockService + Send + Sync
type BlockService: BlockService + Send + Sync
The implementation of the block service.
sourcetype FragmentService: FragmentService + Send + Sync
type FragmentService: FragmentService + Send + Sync
The implementation of the fragment service.
sourcetype GossipService: GossipService + Send + Sync
type GossipService: GossipService + Send + Sync
The implementation of the gossip service.
Required Methods§
sourcefn handshake<'life0, 'life1, 'async_trait>(
&'life0 self,
peer: Peer,
nonce: &'life1 [u8]
) -> Pin<Box<dyn Future<Output = Result<HandshakeResponse, Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn handshake<'life0, 'life1, 'async_trait>( &'life0 self, peer: Peer, nonce: &'life1 [u8] ) -> Pin<Box<dyn Future<Output = Result<HandshakeResponse, Error>> + Send + 'async_trait>>where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,
Implements node handshake. The server returns the ID of the genesis
block and its own node ID, authenticated with the signature of nonce
.
sourcefn client_auth<'life0, 'async_trait>(
&'life0 self,
peer: Peer,
auth: AuthenticatedNodeId
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn client_auth<'life0, 'async_trait>( &'life0 self, peer: Peer, auth: AuthenticatedNodeId ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where Self: 'async_trait, 'life0: 'async_trait,
Handles client ID authentication.
sourcefn block_service(&self) -> Option<&Self::BlockService>
fn block_service(&self) -> Option<&Self::BlockService>
Instantiates the block service, if supported by this node.
sourcefn fragment_service(&self) -> Option<&Self::FragmentService>
fn fragment_service(&self) -> Option<&Self::FragmentService>
Instantiates the fragment service, if supported by this node.
sourcefn gossip_service(&self) -> Option<&Self::GossipService>
fn gossip_service(&self) -> Option<&Self::GossipService>
Instantiates the gossip service, if supported by this node.