Skip to content

Commit 5bc7318

Browse files
committed
clippy
1 parent 6c5db71 commit 5bc7318

File tree

5 files changed

+21
-28
lines changed

5 files changed

+21
-28
lines changed

content-discovery/README.md

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
# Iroh content discovery
22

3-
This library provides global content discovery for iroh.
3+
This rust workspace provides global content discovery for iroh.
4+
5+
*iroh-mainline-content-discovery* is a library that provides a discovery protocol,
6+
a client implementation, and a client command line utility.
7+
8+
*iroh-mainline-tracker* is a server implementation for the content discovery
9+
protocol.
410

511
## Building from source
612

@@ -9,12 +15,12 @@ Make sure you have an up to date version of [rust](https://www.rust-lang.org/) i
915
`cargo` for your platform.
1016

1117
Then run `cargo build --release` from the root directory. The resulting binary
12-
will be in `target/release/tracker`
18+
will be in `target/release/iroh-mainline-tracker`
1319

1420
## Running the tracker
1521

1622
```sh
17-
tracker server
23+
iroh-mainline-tracker
1824
```
1925

2026
Will run the server with a persistent node id and announce information.
@@ -24,7 +30,7 @@ Will run the server with a persistent node id and announce information.
2430
When announcing content, you can give either iroh tickets or content hashes.
2531

2632
```sh
27-
tracker announce \
33+
iroh-mainline-content-discovery announce \
2834
--tracker t3od3nblvk6csozc3oe7rjum7oebnnwwfkebolbxf2o66clzdyha \
2935
blob:ealcoyhcjxyklzee4manl3b5see3k3nwekf6npw5oollcsflrsduiaicaiafetezhwjouayaycuadbes5ibqaq7qasiyqmqo74ijal7k7ec4pni5htntx4tpoawgvmbhaa3txa4uaa
3036
```
@@ -36,7 +42,7 @@ When querying content, you can use tickets, hashes, or hash and format.
3642
When using tickets, the address part of the ticket will be ignored.
3743

3844
```sh
39-
tracker query \
45+
iroh-mainline-content-discovery query \
4046
--tracker t3od3nblvk6csozc3oe7rjum7oebnnwwfkebolbxf2o66clzdyha \
4147
blob:ealcoyhcjxyklzee4manl3b5see3k3nwekf6npw5oollcsflrsduiaicaiafetezhwjouayaycuadbes5ibqaq7qasiyqmqo74ijal7k7ec4pni5htntx4tpoawgvmbhaa3txa4uaa
4248
```

content-discovery/iroh-mainline-content-discovery/src/client.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ impl std::str::FromStr for TrackerId {
257257
pub async fn connect(tracker: &TrackerId, local_port: u16) -> anyhow::Result<quinn::Connection> {
258258
match tracker {
259259
TrackerId::Addr(tracker) => connect_socket(*tracker, local_port).await,
260-
TrackerId::NodeId(tracker) => connect_magic(&tracker, local_port).await,
260+
TrackerId::NodeId(tracker) => connect_magic(tracker, local_port).await,
261261
}
262262
}
263263

content-discovery/iroh-mainline-tracker/src/args.rs

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,8 @@
11
//! Command line arguments.
2-
use clap::{Parser, Subcommand};
2+
use clap::Parser;
33

44
#[derive(Parser, Debug)]
55
pub struct Args {
6-
#[clap(subcommand)]
7-
pub command: Commands,
8-
}
9-
10-
#[derive(Subcommand, Debug)]
11-
pub enum Commands {
12-
Server(ServerArgs),
13-
}
14-
15-
#[derive(Parser, Debug)]
16-
pub struct ServerArgs {
176
/// The port to listen on.
187
#[clap(long, default_value_t = 0xacacu16)]
198
pub magic_port: u16,

content-discovery/iroh-mainline-tracker/src/main.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ use iroh_pkarr_node_discovery::PkarrNodeDiscovery;
2828
use tokio::io::AsyncWriteExt;
2929
use tokio_util::task::LocalPoolHandle;
3030

31-
use crate::args::{Args, Commands, ServerArgs};
31+
use crate::args::Args;
3232

3333
static VERBOSE: AtomicBool = AtomicBool::new(false);
3434

@@ -100,7 +100,7 @@ fn write_defaults() -> anyhow::Result<()> {
100100
Ok(())
101101
}
102102

103-
async fn server(args: ServerArgs) -> anyhow::Result<()> {
103+
async fn server(args: Args) -> anyhow::Result<()> {
104104
set_verbose(!args.quiet);
105105
let tpc = LocalPoolHandle::new(2);
106106
let home = tracker_home()?;
@@ -143,9 +143,7 @@ async fn server(args: ServerArgs) -> anyhow::Result<()> {
143143
async fn main() -> anyhow::Result<()> {
144144
setup_logging();
145145
let args = Args::parse();
146-
match args.command {
147-
Commands::Server(args) => server(args).await,
148-
}
146+
server(args).await
149147
}
150148

151149
/// Returns default server configuration along with its certificate.

content-discovery/iroh-mainline-tracker/src/tracker.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -165,10 +165,10 @@ impl Tracker {
165165
pub async fn dht_announce_loop(self, port: u16) -> anyhow::Result<()> {
166166
let dht = mainline::Dht::default();
167167
loop {
168-
let state = self.0.state.read().unwrap();
169-
let content: BTreeSet<HashAndFormat> =
170-
state.announce_data.iter().map(|(haf, _)| *haf).collect();
171-
drop(state);
168+
let content: BTreeSet<HashAndFormat> = {
169+
let state = self.0.state.read().unwrap();
170+
state.announce_data.keys().copied().collect()
171+
};
172172
let mut announce = announce_dht(
173173
dht.clone(),
174174
content,
@@ -489,7 +489,7 @@ impl Tracker {
489489
)> {
490490
let t0 = Instant::now();
491491
let res = endpoint
492-
.connect_by_node_id(&host, &iroh_bytes::protocol::ALPN)
492+
.connect_by_node_id(&host, iroh_bytes::protocol::ALPN)
493493
.await;
494494
log_connection_attempt(&self.0.options.dial_log, &host, t0, &res)?;
495495
let connection = match res {

0 commit comments

Comments
 (0)