Kagome
Polkadot Runtime Engine in C++17
kagome::network::RequestResponseProtocol< Request, Response, ReadWriter > Struct Template Referenceabstract

#include <request_response_protocol.hpp>

Inheritance diagram for kagome::network::RequestResponseProtocol< Request, Response, ReadWriter >:
Collaboration diagram for kagome::network::RequestResponseProtocol< Request, Response, ReadWriter >:

Public Types

using RequestType = Request
 
using ResponseType = Response
 
using ReadWriterType = ReadWriter
 

Public Member Functions

 RequestResponseProtocol (libp2p::Host &host, Protocol const &protocol, ProtocolName const &name)
 
virtual ~RequestResponseProtocol ()
 
bool start () override
 
bool stop () override
 
const ProtocolprotocolName () const override
 
void doRequest (const PeerId &peer_id, RequestType request, std::function< void(outcome::result< ResponseType >)> &&response_handler)
 
- Public Member Functions inherited from kagome::network::ProtocolBase
 ProtocolBase ()=default
 
 ProtocolBase (ProtocolBase &&) noexcept=delete
 
 ProtocolBase (const ProtocolBase &)=delete
 
virtual ~ProtocolBase ()=default
 
ProtocolBaseoperator= (ProtocolBase &&) noexcept=delete
 
ProtocolBaseoperator= (ProtocolBase const &)=delete
 

Protected Member Functions

virtual outcome::result< ResponseTypeonRxRequest (RequestType request, std::shared_ptr< Stream > stream)=0
 
virtual void onTxRequest (RequestType const &request)=0
 
ProtocolBaseImplbase ()
 

Private Member Functions

void onIncomingStream (std::shared_ptr< Stream > stream) override
 
void newOutgoingStream (const PeerInfo &peer_info, std::function< void(outcome::result< std::shared_ptr< Stream >>)> &&cb) override
 
template<typename M >
void write (std::shared_ptr< Stream > stream, M msg, std::function< void(outcome::result< void >, std::shared_ptr< Stream >)> &&cb)
 
void writeRequest (std::shared_ptr< Stream > stream, RequestType request, std::function< void(outcome::result< ResponseType >)> &&cb)
 
void writeResponse (std::shared_ptr< Stream > stream, ResponseType response)
 
template<typename M >
void read (std::shared_ptr< Stream > stream, std::function< void(outcome::result< M >, std::shared_ptr< Stream >)> &&cb)
 
void readResponse (std::shared_ptr< Stream > stream, std::function< void(outcome::result< ResponseType >)> &&cb)
 
void readRequest (std::shared_ptr< Stream > stream)
 

Private Attributes

ProtocolBaseImpl base_
 
Protocol const protocol_
 

Friends

class ProtocolBaseImpl
 

Detailed Description

template<typename Request, typename Response, typename ReadWriter>
struct kagome::network::RequestResponseProtocol< Request, Response, ReadWriter >

Definition at line 18 of file request_response_protocol.hpp.

Member Typedef Documentation

template<typename Request, typename Response, typename ReadWriter>
using kagome::network::RequestResponseProtocol< Request, Response, ReadWriter >::ReadWriterType = ReadWriter

Definition at line 24 of file request_response_protocol.hpp.

template<typename Request, typename Response, typename ReadWriter>
using kagome::network::RequestResponseProtocol< Request, Response, ReadWriter >::RequestType = Request

Definition at line 22 of file request_response_protocol.hpp.

template<typename Request, typename Response, typename ReadWriter>
using kagome::network::RequestResponseProtocol< Request, Response, ReadWriter >::ResponseType = Response

Definition at line 23 of file request_response_protocol.hpp.

Constructor & Destructor Documentation

template<typename Request, typename Response, typename ReadWriter>
kagome::network::RequestResponseProtocol< Request, Response, ReadWriter >::RequestResponseProtocol ( libp2p::Host &  host,
Protocol const &  protocol,
ProtocolName const &  name 
)
inline

Definition at line 26 of file request_response_protocol.hpp.

template<typename Request, typename Response, typename ReadWriter>
virtual kagome::network::RequestResponseProtocol< Request, Response, ReadWriter >::~RequestResponseProtocol ( )
inlinevirtual

Definition at line 30 of file request_response_protocol.hpp.

Member Function Documentation

template<typename Request, typename Response, typename ReadWriter>
ProtocolBaseImpl& kagome::network::RequestResponseProtocol< Request, Response, ReadWriter >::base ( )
inlineprotected

Definition at line 90 of file request_response_protocol.hpp.

template<typename Request, typename Response, typename ReadWriter>
void kagome::network::RequestResponseProtocol< Request, Response, ReadWriter >::doRequest ( const PeerId peer_id,
RequestType  request,
std::function< void(outcome::result< ResponseType >)> &&  response_handler 
)
inline

Definition at line 43 of file request_response_protocol.hpp.

template<typename Request, typename Response, typename ReadWriter>
void kagome::network::RequestResponseProtocol< Request, Response, ReadWriter >::newOutgoingStream ( const PeerInfo peer_info)
inlineoverrideprivatevirtual

Implements kagome::network::ProtocolBase.

Definition at line 102 of file request_response_protocol.hpp.

template<typename Request, typename Response, typename ReadWriter>
void kagome::network::RequestResponseProtocol< Request, Response, ReadWriter >::onIncomingStream ( std::shared_ptr< Stream stream)
inlineoverrideprivatevirtual

Implements kagome::network::ProtocolBase.

Definition at line 97 of file request_response_protocol.hpp.

template<typename Request, typename Response, typename ReadWriter>
virtual outcome::result<ResponseType> kagome::network::RequestResponseProtocol< Request, Response, ReadWriter >::onRxRequest ( RequestType  request,
std::shared_ptr< Stream stream 
)
protectedpure virtual
template<typename Request, typename Response, typename ReadWriter>
virtual void kagome::network::RequestResponseProtocol< Request, Response, ReadWriter >::onTxRequest ( RequestType const &  request)
protectedpure virtual
template<typename Request, typename Response, typename ReadWriter>
const Protocol& kagome::network::RequestResponseProtocol< Request, Response, ReadWriter >::protocolName ( ) const
inlineoverridevirtual

Implements kagome::network::ProtocolBase.

Definition at line 39 of file request_response_protocol.hpp.

template<typename Request, typename Response, typename ReadWriter>
template<typename M >
void kagome::network::RequestResponseProtocol< Request, Response, ReadWriter >::read ( std::shared_ptr< Stream stream,
std::function< void(outcome::result< M >, std::shared_ptr< Stream >)> &&  cb 
)
inlineprivate

Definition at line 221 of file request_response_protocol.hpp.

template<typename Request, typename Response, typename ReadWriter>
void kagome::network::RequestResponseProtocol< Request, Response, ReadWriter >::readRequest ( std::shared_ptr< Stream stream)
inlineprivate

Definition at line 278 of file request_response_protocol.hpp.

template<typename Request, typename Response, typename ReadWriter>
void kagome::network::RequestResponseProtocol< Request, Response, ReadWriter >::readResponse ( std::shared_ptr< Stream stream,
std::function< void(outcome::result< ResponseType >)> &&  cb 
)
inlineprivate

Definition at line 261 of file request_response_protocol.hpp.

template<typename Request, typename Response, typename ReadWriter>
bool kagome::network::RequestResponseProtocol< Request, Response, ReadWriter >::start ( )
inlineoverridevirtual

Implements kagome::network::ProtocolBase.

Definition at line 32 of file request_response_protocol.hpp.

template<typename Request, typename Response, typename ReadWriter>
bool kagome::network::RequestResponseProtocol< Request, Response, ReadWriter >::stop ( )
inlineoverridevirtual

Implements kagome::network::ProtocolBase.

Definition at line 35 of file request_response_protocol.hpp.

template<typename Request, typename Response, typename ReadWriter>
template<typename M >
void kagome::network::RequestResponseProtocol< Request, Response, ReadWriter >::write ( std::shared_ptr< Stream stream,
msg,
std::function< void(outcome::result< void >, std::shared_ptr< Stream >)> &&  cb 
)
inlineprivate

Definition at line 139 of file request_response_protocol.hpp.

template<typename Request, typename Response, typename ReadWriter>
void kagome::network::RequestResponseProtocol< Request, Response, ReadWriter >::writeRequest ( std::shared_ptr< Stream stream,
RequestType  request,
std::function< void(outcome::result< ResponseType >)> &&  cb 
)
inlineprivate

Definition at line 184 of file request_response_protocol.hpp.

template<typename Request, typename Response, typename ReadWriter>
void kagome::network::RequestResponseProtocol< Request, Response, ReadWriter >::writeResponse ( std::shared_ptr< Stream stream,
ResponseType  response 
)
inlineprivate

Definition at line 205 of file request_response_protocol.hpp.

Friends And Related Function Documentation

template<typename Request, typename Response, typename ReadWriter>
friend class ProtocolBaseImpl
friend

Definition at line 95 of file request_response_protocol.hpp.

Member Data Documentation

template<typename Request, typename Response, typename ReadWriter>
ProtocolBaseImpl kagome::network::RequestResponseProtocol< Request, Response, ReadWriter >::base_
private

Definition at line 306 of file request_response_protocol.hpp.

template<typename Request, typename Response, typename ReadWriter>
Protocol const kagome::network::RequestResponseProtocol< Request, Response, ReadWriter >::protocol_
private

Definition at line 307 of file request_response_protocol.hpp.


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