Skip to content

deps/refactor: port to iroh 0.90 #47

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

Open
wants to merge 19 commits into
base: main
Choose a base branch
from
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
2,117 changes: 878 additions & 1,239 deletions Cargo.lock

Large diffs are not rendered by default.

128 changes: 54 additions & 74 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,109 +11,89 @@ repository = "https://github.com/n0-computer/iroh-docs"
# Sadly this also needs to be updated in .github/workflows/ci.yml
rust-version = "1.81"

[lints.rust]
missing_debug_implementations = "warn"

# We use this --cfg for documenting the cargo features on which an API
# is available. To preview this locally use: RUSTFLAGS="--cfg
# iroh_docsrs cargo +nightly doc --all-features". We use our own
# iroh_docsrs instead of the common docsrs to avoid also enabling this
# feature in any dependencies, because some indirect dependencies
# require a feature enabled when using `--cfg docsrs` which we can not
# do. To enable for a crate set `#![cfg_attr(iroh_docsrs,
# feature(doc_cfg))]` in the crate.
unexpected_cfgs = { level = "warn", check-cfg = ["cfg(iroh_docsrs)"] }

[dependencies]
anyhow = "1"
async-channel = "2.3.1"
blake3 = { package = "iroh-blake3", version = "1.4.5"}
blake3 = "1.8"
bytes = { version = "1.7", features = ["serde"] }
derive_more = { version = "1.0.0", features = ["debug", "deref", "display", "from", "try_into", "into", "as_ref"] }
derive_more = { version = "1.0.0", features = [
"debug",
"deref",
"display",
"from",
"try_into",
"into",
"as_ref",
] }
ed25519-dalek = { version = "2.0.0", features = ["serde", "rand_core"] }
futures-buffered = "0.2.4"
futures-lite = "2.3.0"
futures-util = { version = "0.3.25" }
hex = "0.4"
iroh-base = { version = "0.35", features = ["ticket"] }
iroh-blobs = { version = "0.35" }
iroh-gossip = { version = "0.35", optional = true, features = ["net"] }
iroh-metrics = { version = "0.34", default-features = false }
iroh = { version = "0.35", optional = true }
iroh = { version = "0.90" }
iroh-base = { version = "0.90", features = ["ticket"] }
iroh-blobs = { version = "0.90" }
iroh-gossip = { version = "0.90", features = ["net"] }
iroh-metrics = { version = "0.35", default-features = false }
irpc = { version = "0.5.0" }
n0-future = "0.1.3"
num_enum = "0.7"
postcard = { version = "1", default-features = false, features = ["alloc", "use-std", "experimental-derive"] }
postcard = { version = "1", default-features = false, features = [
"alloc",
"use-std",
"experimental-derive",
] }
quinn = { package = "iroh-quinn", version = "0.14.0" }
rand = "0.8.5"
rand_core = "0.6.4"
redb = { version = "2.0.0" }
redb_v1 = { package = "redb", version = "1.5.1" }
redb_v1 = { package = "redb", version = "1.5.1" }
self_cell = "1.0.3"
serde = { version = "1.0.164", features = ["derive"] }
serde-error = "0.1.3"
strum = { version = "0.26", features = ["derive"] }
tempfile = { version = "3.4" }
thiserror = "2"
tokio = { version = "1", features = ["sync", "rt", "time", "macros"] }
tokio-stream = { version = "0.1", optional = true, features = ["sync"]}
tokio-util = { version = "0.7.12", optional = true, features = ["codec", "io-util", "io", "rt"] }
tokio = { version = "1", features = ["sync", "rt", "time", "io-util"] }
tokio-stream = { version = "0.1", features = ["sync"] }
tokio-util = { version = "0.7.12", features = ["codec", "io-util", "io", "rt"] }
tracing = "0.1"

# rpc
nested_enum_utils = { version = "0.1.0", optional = true }
quic-rpc = { version = "0.20", optional = true }
quic-rpc-derive = { version = "0.20", optional = true }
serde-error = { version = "0.1.3", optional = true }
portable-atomic = { version = "1.9.0", optional = true }

# cli
clap = { version = "4", features = ["derive"], optional = true }
console = { version = "0.15", optional = true }
data-encoding = { version = "2.3.3", optional = true }
indicatif = { version = "0.17", features = ["tokio"], optional = true }
dialoguer = { version = "0.11", optional = true }
colored = { version = "2.1", optional = true }
shellexpand = { version = "3.1", optional = true }

[dev-dependencies]
rand_chacha = "0.3.1"
tokio = { version = "1", features = ["sync", "macros"] }
data-encoding = "2.6.0"
iroh = { version = "0.90", features = ["test-utils"] }
nested_enum_utils = "0.1.0"
parking_lot = "0.12.3"
proptest = "1.2.0"
rand_chacha = "0.3.1"
tempfile = "3.4"
tracing-test = "0.2.5"
test-strategy = "0.4"
tracing-subscriber = { version = "0.3.18", features = ["env-filter"] }
parking_lot = "0.12.3"
testresult = "0.4.1"
nested_enum_utils = "0.1.0"
iroh-io = "0.6.1"
testdir = "0.7"
data-encoding = "2.6.0"
testresult = "0.4.1"
tokio = { version = "1", features = ["sync", "macros"] }
tracing-subscriber = { version = "0.3.18", features = ["env-filter"] }
tracing-test = "0.2.5"

[features]
default = ["net", "metrics", "engine", "test-utils"]
net = ["dep:iroh", "tokio/io-util", "dep:tokio-stream", "dep:tokio-util"]
default = ["metrics"]
metrics = ["iroh-metrics/metrics", "iroh/metrics"]
engine = ["net", "dep:iroh-gossip", "iroh-blobs/downloader"]
test-utils = ["iroh/test-utils"]
cli = [
"rpc",
"dep:clap",
"dep:indicatif",
"dep:console",
"dep:colored",
"dep:dialoguer",
"dep:shellexpand",
"dep:data-encoding",
"iroh-blobs/rpc",
]
rpc = [
"engine",
"dep:nested_enum_utils",
"dep:quic-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"]

[lints.rust]
missing_debug_implementations = "warn"

# We use this --cfg for documenting the cargo features on which an API
# is available. To preview this locally use: RUSTFLAGS="--cfg
# iroh_docsrs cargo +nightly doc --all-features". We use our own
# iroh_docsrs instead of the common docsrs to avoid also enabling this
# feature in any dependencies, because some indirect dependencies
# require a feature enabled when using `--cfg docsrs` which we can not
# do. To enable for a crate set `#![cfg_attr(iroh_docsrs,
# feature(doc_cfg))]` in the crate.
unexpected_cfgs = { level = "warn", check-cfg = ["cfg(iroh_docsrs)"] }

[patch.crates-io]
iroh-blobs = { git = "https://github.com/n0-computer/iroh-blobs", branch = "Frando/gc-protect" }
24 changes: 13 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ Here is a basic example of how to set up `iroh-docs` with `iroh`:

```rust
use iroh::{protocol::Router, Endpoint};
use iroh_blobs::{net_protocol::Blobs, util::local_pool::LocalPool, ALPN as BLOBS_ALPN};
use iroh_blobs::{net_protocol::Blobs, store::mem::MemStore, ALPN as BLOBS_ALPN};
use iroh_docs::{protocol::Docs, ALPN as DOCS_ALPN};
use iroh_gossip::{net::Gossip, ALPN as GOSSIP_ALPN};

Expand All @@ -53,23 +53,25 @@ async fn main() -> anyhow::Result<()> {
// we've built at number0
let endpoint = Endpoint::builder().discovery_n0().bind().await?;

// create a router builder, we will add the
// protocols to this builder and then spawn
// the router
let builder = Router::builder(endpoint);

// build the blobs protocol
let blobs = Blobs::memory().build(builder.endpoint());
let blobs = MemStore::default();

// build the gossip protocol
let gossip = Gossip::builder().spawn(builder.endpoint().clone()).await?;
let gossip = Gossip::builder().spawn(endpoint.clone());

// build the docs protocol
let docs = Docs::memory().spawn(&blobs, &gossip).await?;
let docs = Docs::memory()
.spawn(endpoint.clone(), (*blobs).clone(), gossip.clone())
.await?;

// create a router builder, we will add the
// protocols to this builder and then spawn
// the router
let builder = Router::builder(endpoint.clone());

// setup router
let router = builder
.accept(BLOBS_ALPN, blobs)
let _router = builder
.accept(BLOBS_ALPN, Blobs::new(&blobs, endpoint.clone(), None))
.accept(GOSSIP_ALPN, gossip)
.accept(DOCS_ALPN, docs)
.spawn();
Expand Down
37 changes: 37 additions & 0 deletions examples/setup.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
use iroh::{protocol::Router, Endpoint};
use iroh_blobs::{net_protocol::Blobs, store::mem::MemStore, ALPN as BLOBS_ALPN};
use iroh_docs::{protocol::Docs, ALPN as DOCS_ALPN};
use iroh_gossip::{net::Gossip, ALPN as GOSSIP_ALPN};

#[tokio::main]
async fn main() -> anyhow::Result<()> {
// create an iroh endpoint that includes the standard discovery mechanisms
// we've built at number0
let endpoint = Endpoint::builder().discovery_n0().bind().await?;

// build the blobs protocol
let blobs = MemStore::default();

// build the gossip protocol
let gossip = Gossip::builder().spawn(endpoint.clone());

// build the docs protocol
let docs = Docs::memory()
.spawn(endpoint.clone(), (*blobs).clone(), gossip.clone())
.await?;

// create a router builder, we will add the
// protocols to this builder and then spawn
// the router
let builder = Router::builder(endpoint.clone());

// setup router
let _router = builder
.accept(BLOBS_ALPN, Blobs::new(&blobs, endpoint.clone(), None))
.accept(GOSSIP_ALPN, gossip)
.accept(DOCS_ALPN, docs)
.spawn();

// do fun stuff with docs!
Ok(())
}
Loading
Loading