@@ -734,20 +734,26 @@ 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
+ ///
745
+ /// The returned `Option`s will only be `Some` if an address had been previously given via
746
+ /// [`Self::new_outbound_connection`] or [`Self::new_inbound_connection`].
747
+ pub fn get_peer_node_ids ( & self ) -> Vec < ( PublicKey , Option < NetAddress > ) > {
743
748
let peers = self . peers . read ( ) . unwrap ( ) ;
744
749
peers. values ( ) . filter_map ( |peer_mutex| {
745
750
let p = peer_mutex. lock ( ) . unwrap ( ) ;
746
- if !p. channel_encryptor . is_ready_for_encryption ( ) || p. their_features . is_none ( ) {
751
+ if !p. channel_encryptor . is_ready_for_encryption ( ) || p. their_features . is_none ( ) ||
752
+ p. their_node_id . is_none ( ) {
747
753
return None ;
748
754
}
749
- p. their_node_id
750
- } ) . map ( | ( node_id , _ ) | node_id ) . collect ( )
755
+ Some ( ( p. their_node_id . unwrap ( ) . 0 , p . their_net_address . clone ( ) ) )
756
+ } ) . collect ( )
751
757
}
752
758
753
759
fn get_ephemeral_key ( & self ) -> SecretKey {
@@ -757,7 +763,7 @@ impl<Descriptor: SocketDescriptor, CM: Deref, RM: Deref, OM: Deref, L: Deref, CM
757
763
SecretKey :: from_slice ( & Sha256 :: from_engine ( ephemeral_hash) . into_inner ( ) ) . expect ( "You broke SHA-256!" )
758
764
}
759
765
760
- /// Indicates a new outbound connection has been established to a node with the given node_id
766
+ /// Indicates a new outbound connection has been established to a node with the given ` node_id`
761
767
/// and an optional remote network address.
762
768
///
763
769
/// The remote network address adds the option to report a remote IP address back to a connecting
0 commit comments