scatter_net/legacy/net/methods/connect_to.rs
1use anyhow::Result;
2use iroh::NodeId;
3
4use crate::{Peer, PeerState, ScatterNet, ALPN};
5
6impl ScatterNet {
7 pub async fn connect_to(&self, node_id: NodeId, state: Option<PeerState>) -> Result<Peer> {
8 eprintln!("Attempting connection to {node_id}");
9
10 let connection = self.endpoint.connect(node_id, ALPN).await?;
11
12 eprintln!("Connection established to {node_id}");
13
14 Self::init_peer(self, connection, state)
15 }
16}