@@ -734,20 +734,23 @@ impl<Descriptor: SocketDescriptor, CM: Deref, RM: Deref, OM: Deref, L: Deref, CM
734
734
}
735
735
}
736
736
737
- /// Get the list of node ids for peers which have completed the initial handshake.
737
+ /// Get a list of tuples mapping from node id to network addresses for peers which have
738
+ /// completed the initial handshake.
738
739
///
739
- /// For outbound connections, this will be the same as the their_node_id parameter passed in to
740
- /// new_outbound_connection, however entries will only appear once the initial handshake has
741
- /// completed and we are sure the remote peer has the private key for the given node_id.
742
- pub fn get_peer_node_ids ( & self ) -> Vec < PublicKey > {
740
+ /// For outbound connections, the [`PublicKey`] will be the same as the `their_node_id` parameter
741
+ /// passed in to [`Self::new_outbound_connection`], however entries will only appear once the initial
742
+ /// handshake has completed and we are sure the remote peer has the private key for the given
743
+ /// [`PublicKey`].
744
+ pub fn get_peer_node_ids ( & self ) -> Vec < ( PublicKey , Option < NetAddress > ) > {
743
745
let peers = self . peers . read ( ) . unwrap ( ) ;
744
746
peers. values ( ) . filter_map ( |peer_mutex| {
745
747
let p = peer_mutex. lock ( ) . unwrap ( ) ;
746
- if !p. channel_encryptor . is_ready_for_encryption ( ) || p. their_features . is_none ( ) {
748
+ if !p. channel_encryptor . is_ready_for_encryption ( ) || p. their_features . is_none ( ) ||
749
+ p. their_node_id . is_none ( ) {
747
750
return None ;
748
751
}
749
- p. their_node_id
750
- } ) . map ( | ( node_id , _ ) | node_id ) . collect ( )
752
+ Some ( ( p. their_node_id . unwrap ( ) . 0 , p . their_net_address . clone ( ) ) )
753
+ } ) . collect ( )
751
754
}
752
755
753
756
fn get_ephemeral_key ( & self ) -> SecretKey {
@@ -757,7 +760,7 @@ impl<Descriptor: SocketDescriptor, CM: Deref, RM: Deref, OM: Deref, L: Deref, CM
757
760
SecretKey :: from_slice ( & Sha256 :: from_engine ( ephemeral_hash) . into_inner ( ) ) . expect ( "You broke SHA-256!" )
758
761
}
759
762
760
- /// Indicates a new outbound connection has been established to a node with the given node_id
763
+ /// Indicates a new outbound connection has been established to a node with the given ` node_id`
761
764
/// and an optional remote network address.
762
765
///
763
766
/// The remote network address adds the option to report a remote IP address back to a connecting
0 commit comments