pub async fn request(
		&self,
		target: PeerId,
		protocol: impl Into<Cow<'static, str>>,
		request: Vec<u8>
	) -> Result<Vec<u8>, RequestFailure> {
		let (tx, rx) = oneshot::channel();
		let _ = self.to_worker.unbounded_send(ServiceToWorkerMsg::Request {
			target,
			protocol: protocol.into(),
			request,
			pending_response: tx
		});

		match rx.await {
			Ok(v) => v,
			// The channel can only be closed if the network worker no longer exists. If the
			// network worker no longer exists, then all connections to `target` are necessarily
			// closed, and we legitimately report this situation as a "ConnectionClosed".
			Err(_) => Err(RequestFailure::Network(OutboundFailure::ConnectionClosed)),
		}
	}
/// Sends a single targeted request to a specific peer. On success, returns the response of
/// the peer.
///
/// Request-response protocols are a way to complement notifications protocols, but
/// notifications should remain the default ways of communicating information. For example, a
/// peer can announce something through a notification, after which the recipient can obtain
/// more information by performing a request.
/// As such, this function is meant to be called only with peers we are already connected to.
/// Calling this method with a `target` we are not connected to will *not* attempt to connect
/// to said peer.
///
/// No limit or throttling of concurrent outbound requests per peer and protocol are enforced.
/// Such restrictions, if desired, need to be enforced at the call site(s).
///
/// The protocol must have been registered through
/// [`NetworkConfiguration::request_response_protocols`](
/// crate::config::NetworkConfiguration::request_response_protocols).
Sends a single targeted request to a specific peer. On success, returns the response of
the peer.

Request-response protocols are a way to complement notifications protocols, but
notifications should remain the default ways of communicating information. For example, a
peer can announce something through a notification, after which the recipient can obtain
more information by performing a request.
As such, this function is meant to be called only with peers we are already connected to.
Calling this method with a `target` we are not connected to will *not* attempt to connect
to said peer.

No limit or throttling of concurrent outbound requests per peer and protocol are enforced.
Such restrictions, if desired, need to be enforced at the call site(s).


Sends a single targeted request to a specific peer . On success returns the response of the peer . Request - response protocols are a way to complement notifications protocols but notifications should remain the default ways of communicating information . For example a peer can announce something through a notification after which the recipient can obtain more information by performing a request . As such this function is meant to be called only with peers we are already connected to . Calling this method with a ` target ` we are not connected to will * not * attempt to connect to said peer . No limit or throttling of concurrent outbound requests per peer and protocol are enforced . Such restrictions if desired need to be enforced at the call site ( s ) .
pub async fn request(
		&self,
		target: PeerId,
		protocol: impl Into<Cow<'static, str>>,
		request: Vec<u8>
	) -> Result<Vec<u8>, RequestFailure> {
		let (tx, rx) = oneshot::channel();
		let _ = self.to_worker.unbounded_send(ServiceToWorkerMsg::Request {
			target,
			protocol: protocol.into(),
			request,
			pending_response: tx
		});
		match rx.await {
			Ok(v) => v,
			// The channel can only be closed if the network worker no longer exists. If the
			// network worker no longer exists, then all connections to `target` are necessarily
			// closed, and we legitimately report this situation as a "ConnectionClosed".
			Err(_) => Err(RequestFailure::Network(OutboundFailure::ConnectionClosed)),
		}
	}
pub async fn request ( & self , target : PeerId , protocol : impl Into < Cow < ' static , str > > , request : Vec < u8 > ) -> Result < Vec < u8 > , RequestFailure > { let ( tx , rx ) = oneshot :: channel ( ) ; let _ = self . to_worker . unbounded_send ( ServiceToWorkerMsg :: Request { target , protocol : protocol . into ( ) , request , pending_response : tx } ) ; match rx . await { Ok ( v ) => v , // The channel can only be closed if the network worker no longer exists. If the // network worker no longer exists, then all connections to `target` are necessarily // closed, and we legitimately report this situation as a "ConnectionClosed". Err ( _ ) => Err ( RequestFailure :: Network ( OutboundFailure :: ConnectionClosed ) ) , } }
Sends a single targeted request to a specific peer.
Sends a single targeted request to a specific peer .
&self
target
PeerId
protocol
impl Into<Cow<'static, str>>
request
Vec<u8>
&self
target
PeerId
protocol
impl Into<Cow<'static, str>>
request
Vec<u8>