@@ -424,7 +424,7 @@ impl<ST: CertificateSignatureRecoverable> PeerDiscovery<ST> {
424424 self . metrics [ GAUGE_PEER_DISC_NUM_PENDING_PEERS ] = self . pending_queue . len ( ) as u64 ;
425425
426426 // send ping to the peer, which will also insert the peer into pending queue
427- Ok ( self . send_ping ( peer_id, name_record. udp_address ( ) , ping_msg) )
427+ Ok ( self . send_ping ( peer_id, name_record. name_record , ping_msg) )
428428 }
429429
430430 fn remove_peer_from_pending (
@@ -619,7 +619,7 @@ where
619619 fn send_ping (
620620 & mut self ,
621621 to : NodeId < CertificateSignaturePubKey < ST > > ,
622- socket_address : SocketAddrV4 ,
622+ name_record : NameRecord ,
623623 ping : Ping < ST > ,
624624 ) -> Vec < PeerDiscoveryCommand < ST > > {
625625 debug ! ( ?to, "sending ping request" ) ;
@@ -630,7 +630,7 @@ where
630630
631631 cmds. push ( PeerDiscoveryCommand :: PingPongCommand {
632632 target : to,
633- socket_address ,
633+ name_record ,
634634 message : PeerDiscoveryMessage :: Ping ( ping) ,
635635 } ) ;
636636
@@ -711,7 +711,7 @@ where
711711 } ;
712712 cmds. push ( PeerDiscoveryCommand :: PingPongCommand {
713713 target : from,
714- socket_address : ping_msg. local_name_record . udp_address ( ) ,
714+ name_record : ping_msg. local_name_record . name_record ,
715715 message : PeerDiscoveryMessage :: Pong ( pong_msg) ,
716716 } ) ;
717717 self . metrics [ GAUGE_PEER_DISC_SEND_PONG ] += 1 ;
@@ -780,13 +780,13 @@ where
780780 cmds. extend ( self . remove_peer_from_pending ( to) ) ;
781781 } else {
782782 // retry ping
783- let socket_address = info. name_record . udp_address ( ) ;
783+ let name_record = info. name_record . name_record . clone ( ) ;
784784 let ping = Ping {
785785 id : self . rng . next_u32 ( ) ,
786786 local_name_record : self . self_record . clone ( ) ,
787787 } ;
788788 info. last_ping = ping. clone ( ) ;
789- cmds. extend ( self . send_ping ( to, socket_address , ping) ) ;
789+ cmds. extend ( self . send_ping ( to, name_record , ping) ) ;
790790 }
791791 }
792792
@@ -1538,6 +1538,13 @@ where
15381538 . map ( |( id, name_record) | ( * id, name_record. clone ( ) ) )
15391539 . collect ( )
15401540 }
1541+
1542+ fn get_name_record (
1543+ & self ,
1544+ id : & NodeId < CertificateSignaturePubKey < ST > > ,
1545+ ) -> Option < & MonadNameRecord < ST > > {
1546+ self . routing_info . get ( id)
1547+ }
15411548}
15421549
15431550#[ cfg( test) ]
@@ -1666,7 +1673,7 @@ mod tests {
16661673 . filter_map ( |c| match c {
16671674 PeerDiscoveryCommand :: PingPongCommand {
16681675 target,
1669- socket_address : _,
1676+ name_record : _,
16701677 message : PeerDiscoveryMessage :: Ping ( ping) ,
16711678 } => Some ( ( target, ping) ) ,
16721679 _ => None ,
@@ -1679,7 +1686,7 @@ mod tests {
16791686 . filter_map ( |c| match c {
16801687 PeerDiscoveryCommand :: PingPongCommand {
16811688 target : _,
1682- socket_address : _,
1689+ name_record : _,
16831690 message : PeerDiscoveryMessage :: Pong ( pong) ,
16841691 } => Some ( pong) ,
16851692 _ => None ,
@@ -1701,7 +1708,8 @@ mod tests {
17011708 id : 12345 ,
17021709 local_name_record : state. self_record . clone ( ) ,
17031710 } ;
1704- let cmds = state. send_ping ( peer1_pubkey, DUMMY_ADDR , ping) ;
1711+ let peer1_name_record = generate_name_record ( peer1, 1 ) . name_record ;
1712+ let cmds = state. send_ping ( peer1_pubkey, peer1_name_record, ping) ;
17051713
17061714 // should send a ping command and schedule a ping timeout
17071715 assert_eq ! ( cmds. len( ) , 2 ) ;
@@ -1714,7 +1722,7 @@ mod tests {
17141722 ) ) ;
17151723 assert ! ( matches!( cmds[ 1 ] , PeerDiscoveryCommand :: PingPongCommand {
17161724 target: _,
1717- socket_address : _,
1725+ name_record : _,
17181726 message: PeerDiscoveryMessage :: Ping ( _)
17191727 } ) ) ;
17201728 }
0 commit comments