Skip to content

Commit 5c064ce

Browse files
committed
Marginally simplify checking if we're already connected
1 parent a16340c commit 5c064ce

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
@@ -749,10 +749,8 @@ fn list_payments(
749749
pub(crate) async fn connect_peer_if_necessary(
750750
pubkey: PublicKey, peer_addr: SocketAddr, peer_manager: Arc<PeerManager>,
751751
) -> Result<(), ()> {
752-
for peer_details in peer_manager.list_peers() {
753-
if peer_details.counterparty_node_id == pubkey {
754-
return Ok(());
755-
}
752+
if peer_manager.peer_by_node_id(&pubkey).is_some() {
753+
return Ok(());
756754
}
757755
let res = do_connect_peer(pubkey, peer_addr, peer_manager).await;
758756
if res.is_err() {

0 commit comments

Comments
 (0)