Kagome
Polkadot Runtime Engine in C++17
kagome::network::RPC< MessageReadWriterT > Struct Template Reference

#include <rpc.hpp>

Collaboration diagram for kagome::network::RPC< MessageReadWriterT >:

Static Public Member Functions

template<typename Request , typename Response >
static void read (std::shared_ptr< libp2p::basic::ReadWriter > read_writer, std::function< outcome::result< Response >(Request)> cb, std::function< void(outcome::result< void >)> error_cb)
 
template<typename Request >
static void read (std::shared_ptr< libp2p::basic::ReadWriter > read_writer, std::function< void(outcome::result< Request >)> cb)
 
template<typename Request , typename Response >
static void write (libp2p::Host &host, const libp2p::peer::PeerInfo &peer_info, const libp2p::peer::Protocol &protocol, Request request, std::function< void(outcome::result< Response >)> cb)
 
template<typename Request >
static void write (libp2p::Host &host, const libp2p::peer::PeerInfo &peer_info, const libp2p::peer::Protocol &protocol, Request request, std::function< void(outcome::result< void >)> cb)
 

Detailed Description

template<typename MessageReadWriterT>
struct kagome::network::RPC< MessageReadWriterT >

Works with RPC requests-responses through the Libp2p

Template Parameters
MessageReadWriterT- type of read-writer to be used; for example, ScaleMessageReadWriter or ProtobufMessageReadWriter

Definition at line 27 of file rpc.hpp.

Member Function Documentation

template<typename MessageReadWriterT >
template<typename Request , typename Response >
static void kagome::network::RPC< MessageReadWriterT >::read ( std::shared_ptr< libp2p::basic::ReadWriter >  read_writer,
std::function< outcome::result< Response >(Request)>  cb,
std::function< void(outcome::result< void >)>  error_cb 
)
inlinestatic

Read an RPC request and answer with a response

Template Parameters
Request- type of the request to be read
Response- type of the response to be written
Parameters
read_writer- channel, from which to read and to which to write
cb,whichis called, when the request is read; it is expected that this function will return a corresponding response
error_cb,whichis called, when error happens during read/write or message processing

Definition at line 39 of file rpc.hpp.

template<typename MessageReadWriterT >
template<typename Request >
static void kagome::network::RPC< MessageReadWriterT >::read ( std::shared_ptr< libp2p::basic::ReadWriter >  read_writer,
std::function< void(outcome::result< Request >)>  cb 
)
inlinestatic

Read an RPC request

Template Parameters
Request- type of the request to be read
Parameters
read_writer- channel, from which to read
cb,whichis called, when the request is read
error_cb,whichis called, when error happens

Definition at line 74 of file rpc.hpp.

template<typename MessageReadWriterT >
template<typename Request , typename Response >
static void kagome::network::RPC< MessageReadWriterT >::write ( libp2p::Host &  host,
const libp2p::peer::PeerInfo &  peer_info,
const libp2p::peer::Protocol &  protocol,
Request  request,
std::function< void(outcome::result< Response >)>  cb 
)
inlinestatic

Write an RPC request and wait for a response

Template Parameters
Request- type of the request to be written
Response- type of the response to be read
Parameters
host,usingwhich to communicate with the network
peer_infoof the peer we want to write the request to
protocol,overwhich we want to write the request to
requestwe want to write
cb,whichis called, when a response arrives, or error happens

Definition at line 99 of file rpc.hpp.

template<typename MessageReadWriterT >
template<typename Request >
static void kagome::network::RPC< MessageReadWriterT >::write ( libp2p::Host &  host,
const libp2p::peer::PeerInfo &  peer_info,
const libp2p::peer::Protocol &  protocol,
Request  request,
std::function< void(outcome::result< void >)>  cb 
)
inlinestatic

Write an RPC request

Template Parameters
Request- type of the request to be written
Parameters
host,usingwhich to communicate with the network
peer_infoof the peer we want to write the request to
protocol,overwhich we want to write the request to
requestwe want to write
cb,whichis called, when a response arrives, or error happens

Definition at line 161 of file rpc.hpp.


The documentation for this struct was generated from the following file: