Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: adapt to new ProtocolHandler
Browse files Browse the repository at this point in the history
rklaehn committed Dec 5, 2024
1 parent 5897668 commit 8135c79
Showing 5 changed files with 31 additions and 59 deletions.
61 changes: 11 additions & 50 deletions Cargo.lock

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

7 changes: 7 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -110,8 +110,15 @@ rpc = [
"dep:quic-rpc-derive",
"dep:serde-error",
"dep:portable-atomic",
"iroh-blobs/rpc",
]

[package.metadata.docs.rs]
all-features = true
rustdoc-args = ["--cfg", "iroh_docsrs"]

[patch.crates-io]
iroh-base = { git = "https://github.com/n0-computer/iroh", branch = "main" }
iroh = { git = "https://github.com/n0-computer/iroh", branch = "main" }
iroh-blobs = { git = "https://github.com/n0-computer/iroh-blobs", branch = "main" }
iroh-gossip = { git = "https://github.com/n0-computer/iroh-gossip", branch = "main" }
6 changes: 5 additions & 1 deletion deny.toml
Original file line number Diff line number Diff line change
@@ -37,4 +37,8 @@ ignore = [
]

[sources]
allow-git = []
allow-git = [
"https://github.com/n0-computer/iroh.git",
"https://github.com/n0-computer/iroh-blobs.git",
"https://github.com/n0-computer/iroh-gossip.git",
]
12 changes: 6 additions & 6 deletions src/protocol.rs
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
//! [`ProtocolHandler`] implementation for the docs [`Engine`].
use std::sync::Arc;

use anyhow::Result;
use futures_lite::future::Boxed as BoxedFuture;
use iroh::{endpoint::Connecting, protocol::ProtocolHandler};

use crate::engine::Engine;

impl<D: iroh_blobs::store::Store> ProtocolHandler for Engine<D> {
fn accept(self: Arc<Self>, conn: Connecting) -> BoxedFuture<Result<()>> {
Box::pin(async move { self.handle_connection(conn).await })
fn accept(&self, conn: Connecting) -> BoxedFuture<Result<()>> {
let this = self.clone();
Box::pin(async move { this.handle_connection(conn).await })
}

fn shutdown(self: Arc<Self>) -> BoxedFuture<()> {
fn shutdown(&self) -> BoxedFuture<()> {
let this = self.clone();
Box::pin(async move {
if let Err(err) = (*self).shutdown().await {
if let Err(err) = this.shutdown().await {
tracing::warn!("shutdown error: {:?}", err);
}
})
4 changes: 2 additions & 2 deletions tests/util.rs
Original file line number Diff line number Diff line change
@@ -144,13 +144,13 @@ impl<S: BlobStore> Builder<S> {
endpoint.clone(),
local_pool.handle().clone(),
);
let blobs = Arc::new(iroh_blobs::net_protocol::Blobs::new(
let blobs = iroh_blobs::net_protocol::Blobs::new(
store.clone(),
local_pool.handle().clone(),
Default::default(),
downloader.clone(),
endpoint.clone(),
));
);
let gossip = iroh_gossip::net::Gossip::from_endpoint(
endpoint.clone(),
Default::default(),

0 comments on commit 8135c79

Please sign in to comment.