Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(iroh)!: Wrap the Connection struct so we own the type #3110

Merged
merged 3 commits into from
Jan 23, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions iroh/examples/dht_discovery.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
use std::str::FromStr;

use clap::Parser;
use iroh::{endpoint::get_remote_node_id, Endpoint, NodeId};
use iroh::{Endpoint, NodeId};
use tracing::warn;
use url::Url;

Expand Down Expand Up @@ -88,7 +88,7 @@ async fn chat_server(args: Args) -> anyhow::Result<()> {
};
tokio::spawn(async move {
let connection = connecting.await?;
let remote_node_id = get_remote_node_id(&connection)?;
let remote_node_id = connection.remote_node_id()?;
println!("got connection from {}", remote_node_id);
// just leave the tasks hanging. this is just an example.
let (mut writer, mut reader) = connection.accept_bi().await?;
Expand Down
2 changes: 1 addition & 1 deletion iroh/examples/echo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ impl ProtocolHandler for Echo {
// Wait for the connection to be fully established.
let connection = connecting.await?;
// We can get the remote's node id from the connection.
let node_id = iroh::endpoint::get_remote_node_id(&connection)?;
let node_id = connection.remote_node_id()?;
println!("accepted connection from {node_id}");

// Our protocol is a simple request-response protocol, so we expect the
Expand Down
2 changes: 1 addition & 1 deletion iroh/examples/listen-unreliable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ async fn main() -> anyhow::Result<()> {
};
let alpn = connecting.alpn().await?;
let conn = connecting.await?;
let node_id = iroh::endpoint::get_remote_node_id(&conn)?;
let node_id = conn.remote_node_id()?;
info!(
"new (unreliable) connection from {node_id} with ALPN {} (coming from {})",
String::from_utf8_lossy(&alpn),
Expand Down
2 changes: 1 addition & 1 deletion iroh/examples/listen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ async fn main() -> anyhow::Result<()> {
};
let alpn = connecting.alpn().await?;
let conn = connecting.await?;
let node_id = iroh::endpoint::get_remote_node_id(&conn)?;
let node_id = conn.remote_node_id()?;
info!(
"new connection from {node_id} with ALPN {} (coming from {})",
String::from_utf8_lossy(&alpn),
Expand Down
4 changes: 2 additions & 2 deletions iroh/examples/search.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ use anyhow::Result;
use clap::Parser;
use futures_lite::future::Boxed as BoxedFuture;
use iroh::{
endpoint::{get_remote_node_id, Connecting},
endpoint::Connecting,
protocol::{ProtocolHandler, Router},
Endpoint, NodeId,
};
Expand Down Expand Up @@ -134,7 +134,7 @@ impl ProtocolHandler for BlobSearch {
// Wait for the connection to be fully established.
let connection = connecting.await?;
// We can get the remote's node id from the connection.
let node_id = get_remote_node_id(&connection)?;
let node_id = connection.remote_node_id()?;
println!("accepted connection from {node_id}");

// Our protocol is a simple request-response protocol, so we expect the
Expand Down
2 changes: 1 addition & 1 deletion iroh/examples/transfer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ async fn provide(
}
};
let conn = connecting.await?;
let node_id = iroh::endpoint::get_remote_node_id(&conn)?;
let node_id = conn.remote_node_id()?;
info!(
"new connection from {node_id} with ALPN {} (coming from {})",
String::from_utf8_lossy(TRANSFER_ALPN),
Expand Down
Loading
Loading