Skip to content

Commit 687edd9

Browse files
committed
clean
1 parent f839b60 commit 687edd9

File tree

1 file changed

+3
-25
lines changed

1 file changed

+3
-25
lines changed

pkgs/id/src/main.rs

Lines changed: 3 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -13,28 +13,19 @@ async fn main() -> anyhow::Result<()> {
1313
let docs = Docs::memory()
1414
.spawn(endpoint.clone(), (*blobs).clone(), gossip.clone())
1515
.await?;
16-
// Grab all passed in arguments, the first one is the binary itself, so we skip it.
1716
let args: Vec<String> = std::env::args().skip(1).collect();
18-
// Convert to &str, so we can pattern-match easily:
1917
let arg_refs: Vec<&str> = args.iter().map(String::as_str).collect();
2018

2119
match arg_refs.as_slice() {
2220
["send", filename] => {
2321
let filename: PathBuf = filename.parse()?;
2422
let abs_path = std::path::absolute(&filename)?;
25-
26-
println!("Hashing file.");
27-
28-
// When we import a blob, we get back a "tag" that refers to said blob in the store
29-
// and allows us to control when/if it gets garbage-collected
3023
let tag = store.blobs().add_path(abs_path).await?;
31-
3224
let node_id = endpoint.id();
3325
let ticket = BlobTicket::new(node_id.into(), tag.hash, tag.format);
3426

35-
println!("File hashed. Fetch this file by running:");
3627
println!(
37-
"cargo run --example transfer -- receive {ticket} {}",
28+
"<binary> receive {ticket} {}",
3829
filename.display()
3930
);
4031

@@ -44,18 +35,12 @@ async fn main() -> anyhow::Result<()> {
4435
.accept(iroh_docs::ALPN, docs)
4536
.spawn();
4637
tokio::signal::ctrl_c().await?;
47-
48-
// Gracefully shut down the node
49-
println!("Shutting down.");
5038
router.shutdown().await?;
5139
}
5240
["receive", ticket, filename] => {
5341
let filename: PathBuf = filename.parse()?;
5442
let abs_path = std::path::absolute(filename)?;
5543
let ticket: BlobTicket = ticket.parse()?;
56-
57-
// For receiving files, we create a "downloader" that allows us to fetch files
58-
// from other nodes via iroh connections
5944
let downloader = store.downloader(&endpoint);
6045

6146
println!("Starting download.");
@@ -70,22 +55,15 @@ async fn main() -> anyhow::Result<()> {
7055
store.blobs().export(ticket.hash(), abs_path).await?;
7156

7257
println!("Finished copying.");
73-
74-
// Gracefully shut down the node
7558
println!("Shutting down.");
59+
7660
endpoint.close().await;
7761
}
7862
_ => {
7963
println!("Couldn't parse command line arguments: {args:?}");
8064
println!("Usage:");
81-
println!(" # to send:");
82-
println!(" cargo run --example transfer -- send [FILE]");
83-
println!(" # this will print a ticket.");
84-
println!();
85-
println!(" # to receive:");
86-
println!(" cargo run --example transfer -- receive [TICKET] [FILE]");
65+
println!(" TODO");
8766
}
8867
}
89-
9068
Ok(())
9169
}

0 commit comments

Comments
 (0)