Skip to content

Commit

Permalink
+ net-iroh missing cargo.toml
Browse files Browse the repository at this point in the history
  • Loading branch information
prekucki committed Nov 18, 2024
1 parent ea5feb9 commit 7475a7d
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 0 deletions.
23 changes: 23 additions & 0 deletions core/net-iroh/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
[package]
name = "net-iroh"
version = "0.1.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
actix-rt.workspace = true
anyhow = "1.0.93"
bincode = "1.3.3"
futures = "0.3.31"
iroh-net = { version = "0.28.1", features = ['discovery-local-network', "iroh-relay"] }
rustyline = "14.0.0"
serde = { version = "1.0.214", features = ["derive"] }
ya-core-model = { workspace = true, features = ["net", "identity"] }
bytes = { version = "1" }
ethsign = { version = "0.8" }



[lints]
workspace = true
43 changes: 43 additions & 0 deletions core/net-iroh/examples/fake.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
use futures::prelude::*;
use iroh_net::discovery::dns::DnsDiscovery;
use iroh_net::discovery::local_swarm_discovery::LocalSwarmDiscovery;
use iroh_net::discovery::pkarr::dht::DhtDiscovery;
use iroh_net::discovery::pkarr::PkarrPublisher;
use iroh_net::discovery::ConcurrentDiscovery;
use iroh_net::key::SecretKey;
use iroh_net::Endpoint;

#[actix_rt::main]
async fn main() -> anyhow::Result<()> {
let secret_key = SecretKey::generate();
let id = secret_key.public();
let dht = DhtDiscovery::builder()
.dht(true)
.secret_key(secret_key.clone())
.build()?;

let discovery = ConcurrentDiscovery::from_services(vec![
Box::new(LocalSwarmDiscovery::new(id)?),
Box::new(dht),
]);
let ep = Endpoint::builder()
.secret_key(secret_key)
.discovery(Box::new(discovery))
.bind()
.await?;

ep.discovery()
.unwrap()
.subscribe()
.unwrap()
.for_each(|di| {
eprintln!("di: {:?}", di);
async { () }
})
.await;

let addr = ep.node_addr().await?;
eprintln!("node addr = {:?}", addr);

Ok(())
}

0 comments on commit 7475a7d

Please sign in to comment.