pub async fn send_and_await_chunk_response<T, E>(
node: &P2PNode,
target_peer: &PeerId,
message_bytes: Vec<u8>,
request_id: u64,
timeout: Duration,
peer_addrs: &[MultiAddr],
response_handler: impl Fn(ChunkMessageBody) -> Option<Result<T, E>>,
send_error: impl FnOnce(String) -> E,
timeout_error: impl FnOnce() -> E,
) -> Result<T, E>Expand description
Send a chunk-protocol message to target_peer and await a matching response.
The event loop filters by topic (CHUNK_PROTOCOL_ID), source peer, decode
errors (warn + skip), and request_id mismatch (skip).
response_handler— inspects the decodedChunkMessageBodyand returns:Some(Ok(T))to resolve successfully,Some(Err(E))to resolve with an error,Noneto keep waiting (wrong variant / not our response).
send_error— produces the caller’s error type whensend_messagefails.timeout_error— produces the caller’s error type on deadline expiry.
§Errors
Returns Err(E) if sending fails (via send_error), the response_handler
returns a protocol-level error, or the deadline expires (via timeout_error).