Support explicit addresses for dialing purposes `send_request`
Right now send_request is dialing peer ID unconditionally. It is destined to fail if none of the behaviors know the address of the peer, as documented in the method itself.
However I am getting addresses in a response to another request and don't really want to persist it in any of the behaviors due to how annoying it is to write and manage them.
The simplest change that would work for me is to add an optional list of addresses to send_request, such that it can still succeed even if behaviors know nothing about this peer.
Not sure if this is the desired approach though. Initially I tried to initiate explicit dial right before calling send_request, but it didn't work because send_request's dial quickly fails and aborts the whole request, so I'll need to do more elaborate workaround, which is unfortunate and unnecessary.
Hi Nazar, you are referring to request_response::Behaviour::send_request right?
If so,
The simplest change that would work for me is to add an optional list of addresses to send_request, such that it can still succeed even if behaviors know nothing about this peer.
how would this work if request_response saves the peers into connected: HashMap<PeerId, SmallVec<[Connection; 2]>>,
Hi Nazar, you are referring to request_response::Behaviour::send_request right?
Yes, what I meant is that for this to include addresses: https://github.com/libp2p/rust-libp2p/blob/d3228adf64cf68f419eeb0b18a5c0b762d29abbe/protocols/request-response/src/lib.rs#L434-L436
Like this:
self.pending_events.push_back(ToSwarm::Dial {
opts: DialOpts::peer_id(*peer).addresses(addresses).build(),
});
I am curious, where do those multiaddresses come from? And can't you dial them as soon as you get them?
Not sure what you mean by that exactly
Sorry Nazar, I misread, reformulated the question
I have a custom request-response protocol, then as described in https://github.com/libp2p/rust-libp2p/issues/5626 if responder doesn't have the data they respond with addresses of closest peers via local Kademlia query. After this application aggregates results and if needed makes requests to some of the newly discovered peers, which swarm may not be aware of at all.