16 CollationFetchingResponse,
17 ScaleMessageReadWriter>,
23 std::shared_ptr<ReqCollationObserver> observer)
29 "ReqCollationProtocol"},
33 outcome::result<CollationFetchingResponse>
onRxRequest(
35 std::shared_ptr<Stream> )
override {
37 return observer_->OnCollationRequest(std::move(request));
41 if (
base().
logger()->level() >= log::Level::DEBUG) {
42 base().
logger()->debug(
"Requesting collation");
47 std::shared_ptr<ReqCollationObserver>
observer_;
54 std::shared_ptr<ReqCollationObserver> observer)
55 : impl_{std::make_shared<ReqCollationProtocolImpl>(
56 host, app_config, chain_spec, std::move(observer))} {}
59 BOOST_ASSERT(
impl_ && !!
"ReqCollationProtocolImpl must be initialized!");
60 return impl_->protocolName();
64 BOOST_ASSERT(
impl_ && !!
"ReqCollationProtocolImpl must be initialized!");
65 return impl_->start();
69 BOOST_ASSERT(
impl_ && !!
"ReqCollationProtocolImpl must be initialized!");
74 BOOST_ASSERT(!
"Must not be called!");
79 std::function<
void(outcome::result<std::shared_ptr<Stream>>)> &&cb) {
80 BOOST_ASSERT(!
"Must not be called!");
86 std::function<
void(outcome::result<CollationFetchingResponse>)>
88 BOOST_ASSERT(
impl_ && !!
"ReqCollationProtocolImpl must be initialized!");
89 return impl_->doRequest(
90 peer_id, std::move(request), std::move(response_handler));
std::shared_ptr< ReqCollationProtocolImpl > impl_
void request(const PeerId &peer_id, CollationFetchingRequest request, std::function< void(outcome::result< CollationFetchingResponse >)> &&response_handler) override
ReqCollationProtocol()=delete
void onIncomingStream(std::shared_ptr< Stream > stream) override
log::Logger const & logger() const
libp2p::peer::PeerInfo PeerInfo
libp2p::peer::Protocol Protocol
libp2p::peer::PeerId PeerId
void newOutgoingStream(const PeerInfo &peer_info, std::function< void(outcome::result< std::shared_ptr< Stream >>)> &&cb) override
ProtocolBaseImpl & base()
const libp2p::peer::Protocol kReqCollationProtocol
ReqCollationProtocolImpl(libp2p::Host &host, application::AppConfiguration const &app_config, application::ChainSpec const &chain_spec, std::shared_ptr< ReqCollationObserver > observer)
virtual void onTxRequest(RequestType const &request)=0
const Protocol & protocolName() const override
virtual outcome::result< ResponseType > onRxRequest(RequestType request, std::shared_ptr< Stream > stream)=0