Skip to content

Commit

Permalink
Use NodeContact instead of Enr for sending talk_req() (#279)
Browse files Browse the repository at this point in the history
  • Loading branch information
KolbyML authored Feb 12, 2025
1 parent c3592f2 commit e2ac53b
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/discv5.rs
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,10 @@ impl<P: ProtocolIdentity> Discv5<P> {
nodes_to_send
}

pub fn ip_mode(&self) -> IpMode {
self.ip_mode
}

/// Mark a node in the routing table as `Disconnected`.
///
/// A `Disconnected` node will be present in the routing table and will be only
Expand Down Expand Up @@ -568,21 +572,19 @@ impl<P: ProtocolIdentity> Discv5<P> {
}
}

/// Request a TALK message from a node, identified via the ENR.
/// Request a TALK message from a node, identified via the NodeContact.
pub fn talk_req(
&self,
enr: Enr,
node_contact: NodeContact,
protocol: Vec<u8>,
request: Vec<u8>,
) -> impl Future<Output = Result<Vec<u8>, RequestError>> + 'static {
// convert the ENR to a node_contact.

let (callback_send, callback_recv) = oneshot::channel();
let channel = self.clone_channel();
let ip_mode = self.ip_mode;

async move {
let node_contact = NodeContact::try_from_enr(enr, ip_mode)?;
let channel = channel.map_err(|_| RequestError::ServiceNotStarted)?;

let event = ServiceRequest::Talk(node_contact, protocol, request, callback_send);
Expand Down

0 comments on commit e2ac53b

Please sign in to comment.