Skip to content

Commit 3a0fffe

Browse files
committed
Marginally simplify checking if we're already connected
1 parent fd355dc commit 3a0fffe

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
@@ -755,10 +755,8 @@ fn list_payments(
755755
pub(crate) async fn connect_peer_if_necessary(
756756
pubkey: PublicKey, peer_addr: SocketAddr, peer_manager: Arc<PeerManager>,
757757
) -> Result<(), ()> {
758-
for peer_details in peer_manager.list_peers() {
759-
if peer_details.counterparty_node_id == pubkey {
760-
return Ok(());
761-
}
758+
if peer_manager.peer_by_node_id(&pubkey).is_some() {
759+
return Ok(());
762760
}
763761
let res = do_connect_peer(pubkey, peer_addr, peer_manager).await;
764762
if res.is_err() {

0 commit comments

Comments
 (0)