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§

source

type BlockService: BlockService + Send + Sync

The implementation of the block service.

source

type FragmentService: FragmentService + Send + Sync

The implementation of the fragment service.

source

type GossipService: GossipService + Send + Sync

The implementation of the gossip service.

Required Methods§

source

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.

source

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.

source

fn block_service(&self) -> Option<&Self::BlockService>

Instantiates the block service, if supported by this node.

source

fn fragment_service(&self) -> Option<&Self::FragmentService>

Instantiates the fragment service, if supported by this node.

source

fn gossip_service(&self) -> Option<&Self::GossipService>

Instantiates the gossip service, if supported by this node.

Implementors§