Skip to content
Open
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
9 changes: 5 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ tracing = { version = "0.1.41", default-features = false }
n0-future = { version = "0.3", default-features = false }
n0-error = { version = "1" }
tracing-subscriber = { version = "0.3.23" }
iroh = { version = "1" }
iroh-base = { version = "1" }
iroh = { version = "1", default-features = false }
iroh-base = { version = "1", default-features = false }
noq = { version = "1", default-features = false }
futures-util = { version = "0.3", features = ["sink"] }
5 changes: 4 additions & 1 deletion irpc-iroh/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,16 @@ serde = { workspace = true }
postcard = { workspace = true, features = ["alloc", "use-std"] }
n0-error = { workspace = true }
n0-future = { workspace = true }
irpc = { version = "0.17.0", path = ".." }
portable-atomic = "1"
irpc = { version = "0.17.0", path = "..", default-features = false, features = ["rpc", "spans", "stream", "derive"] }
Comment thread
rklaehn marked this conversation as resolved.
iroh-base.workspace = true

[target.'cfg(all(target_family = "wasm", target_os = "unknown"))'.dependencies]
getrandom = { version = "0.3", features = ["wasm_js"] }

[dev-dependencies]
# Tests and examples need a crypto provider, which iroh's default features supply.
iroh = { workspace = true, default-features = true }
n0-future = { workspace = true }
tracing-subscriber = { workspace = true, features = ["fmt"] }
irpc-derive = { version = "0.17.0", path = "../irpc-derive" }
Expand Down
18 changes: 6 additions & 12 deletions irpc-iroh/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
use std::{
fmt,
future::Future,
io,
sync::{Arc, atomic::AtomicU64},
};
use std::{fmt, future::Future, io, sync::Arc};

use iroh::{
EndpointId,
Expand All @@ -25,6 +20,9 @@ use irpc::{
};
use n0_error::{Result, e};
use n0_future::{TryFutureExt, future::Boxed as BoxFuture};
// portable-atomic provides AtomicU64 on 32-bit targets (e.g. Xtensa ESP32) that
// lack native 64-bit atomics, same as iroh itself.
use portable_atomic::{AtomicU64, Ordering};
use tracing::{Instrument, debug, error_span, trace, trace_span, warn};

/// Returns a client that connects to a irpc service using an [`iroh::Endpoint`].
Expand Down Expand Up @@ -219,9 +217,7 @@ impl<S: Service> IrohProtocol<S> {
impl<S: Service> ProtocolHandler for IrohProtocol<S> {
async fn accept(&self, connection: Connection) -> Result<(), AcceptError> {
let handler = self.handler.clone();
let request_id = self
.request_id
.fetch_add(1, std::sync::atomic::Ordering::AcqRel);
let request_id = self.request_id.fetch_add(1, Ordering::AcqRel);
let fut = handle_connection::<S>(&connection, handler).map_err(AcceptError::from_err);
let span = trace_span!("rpc", id = request_id);
fut.instrument(span).await
Expand Down Expand Up @@ -267,9 +263,7 @@ impl<S: Service> ProtocolHandler for Iroh0RttProtocol<S> {
async fn on_accepting(&self, accepting: Accepting) -> Result<Connection, AcceptError> {
let zrtt_conn = accepting.into_0rtt();
let handler = self.handler.clone();
let request_id = self
.request_id
.fetch_add(1, std::sync::atomic::Ordering::AcqRel);
let request_id = self.request_id.fetch_add(1, Ordering::AcqRel);
handle_connection::<S>(&zrtt_conn, handler)
.map_err(AcceptError::from_err)
.instrument(trace_span!("rpc", id = request_id))
Expand Down
Loading