Skip to content

Commit e923f41

Browse files
committed
Marginally simplify checking if we're already connected
1 parent 538004c commit e923f41

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

src/cli.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -756,10 +756,8 @@ fn list_payments(
756756
pub(crate) async fn connect_peer_if_necessary(
757757
pubkey: PublicKey, peer_addr: SocketAddr, peer_manager: Arc<PeerManager>,
758758
) -> Result<(), ()> {
759-
for peer_details in peer_manager.list_peers() {
760-
if peer_details.counterparty_node_id == pubkey {
761-
return Ok(());
762-
}
759+
if peer_manager.peer_by_node_id(&pubkey).is_some() {
760+
return Ok(());
763761
}
764762
let res = do_connect_peer(pubkey, peer_addr, peer_manager).await;
765763
if res.is_err() {

0 commit comments

Comments
 (0)