From 4e565cf1d1246c54dcb9e71f9f86521f3993639f Mon Sep 17 00:00:00 2001 From: Blake Griffith Date: Wed, 3 Apr 2024 12:40:25 -0500 Subject: [PATCH 01/11] rm "examples/*" from Cargo.toml [workspace] list This dir does not exist so `cargo` would fail on every command. --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 6325fe2..2eb06ff 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,5 +1,5 @@ [workspace] -members = ["client","server", "common", "corestore", "replicator", "examples/*"] +members = ["client","server", "common", "corestore", "replicator"] [patch.crates-io] hypercore = { git = "https://github.com/Frando/datrs-hypercore", branch = "hyperspace" } From 69efb9999f2dd1ef347d62064e75ed78f8bd0425 Mon Sep 17 00:00:00 2001 From: Blake Griffith Date: Wed, 3 Apr 2024 13:11:03 -0500 Subject: [PATCH 02/11] make `cargo check` work in client --- client/Cargo.toml | 2 +- client/src/bin.rs | 15 ++++++++------- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/client/Cargo.toml b/client/Cargo.toml index acfbaf5..6e1191e 100644 --- a/client/Cargo.toml +++ b/client/Cargo.toml @@ -23,4 +23,4 @@ prost = "0.6.1" chashmap = "2.2.2" parking_lot = { version = "0.11.0", features = ["send_guard"] } hex = "0.4.2" -clap = "3.0.0-beta.1" +clap = { version = "4.5.4", features = ["derive"] } diff --git a/client/src/bin.rs b/client/src/bin.rs index 424398f..1d79b59 100644 --- a/client/src/bin.rs +++ b/client/src/bin.rs @@ -10,7 +10,7 @@ use async_std::prelude::*; use async_std::sync::Arc; use async_std::task; use async_trait::async_trait; -use clap::Clap; +use clap::{Parser, Subcommand}; use env_logger::Env; use futures::io::{AsyncRead, AsyncWrite}; use futures::stream::{StreamExt, TryStreamExt}; @@ -25,24 +25,25 @@ use hyperspace_client::codegen; use hyperspace_client::{RemoteCorestore, RemoteHypercore}; use hyperspace_common::socket_path; -#[derive(Clap, Debug)] +#[derive(Parser, Debug)] +#[command(version, about, long_about = None)] pub struct Opts { /// Hypercore key - #[clap(short, long)] + #[arg(short, long)] pub key: Option, /// Hypercore name - #[clap(short, long)] + #[arg(short, long)] pub name: Option, /// Override socket name to connect to - #[clap(short, long)] + #[arg(short, long)] pub host: Option, - #[clap(subcommand)] + #[command(subcommand)] pub command: Command, } -#[derive(Clap, Debug)] +#[derive(Subcommand, Debug)] pub enum Command { /// Read from a Hypercore Read, From 25be6aa02c80a76bd2c91c7adc6ff0c6f40e80ab Mon Sep 17 00:00:00 2001 From: Blake Griffith Date: Wed, 3 Apr 2024 13:38:56 -0500 Subject: [PATCH 03/11] Depend on bumped hypercore-protocol release --- replicator/Cargo.toml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/replicator/Cargo.toml b/replicator/Cargo.toml index 753924f..f546ae2 100644 --- a/replicator/Cargo.toml +++ b/replicator/Cargo.toml @@ -12,7 +12,8 @@ anyhow = "1.0.31" async-std = { version = "1.9", features = ["unstable"] } futures = "0.3.5" hypercore = { git = "https://github.com/Frando/datrs-hypercore", branch = "hyperspace" } -hypercore-protocol = "0.3.0" +hypercore-protocol = { git = "https://github.com/cowlicks/hypercore-protocol-rs.git", branch = "fix-deps-v3.1" } + # hypercore-protocol = { git = "https://github.com/Frando/hypercore-protocol-rs", branch = "reduce-async" } sparse-bitfield = "0.11.0" hex = "0.4.2" From 9fc9dda3e02d0eea096b6c6ec515d7611b93eb3f Mon Sep 17 00:00:00 2001 From: Blake Griffith Date: Wed, 3 Apr 2024 15:44:23 -0500 Subject: [PATCH 04/11] patch workspace with working libutp-sys --- Cargo.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/Cargo.toml b/Cargo.toml index 2eb06ff..3c67d53 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -4,6 +4,7 @@ members = ["client","server", "common", "corestore", "replicator"] [patch.crates-io] hypercore = { git = "https://github.com/Frando/datrs-hypercore", branch = "hyperspace" } hypercore-protocol = { git = "https://github.com/Frando/hypercore-protocol-rs", branch = "reduce-async" } +libutp-sys = { git = "https://github.com/cowlicks/libutp-sys.git", branch = "fix-build-failure", optional = true } # hrpc = { path = "../hrpc" } # Needed until https://github.com/danburkert/prost/pull/317 is merged. From 0c3f85ea7ccc4a826402397b2097e55c45781555 Mon Sep 17 00:00:00 2001 From: Blake Griffith Date: Wed, 3 Apr 2024 16:28:52 -0500 Subject: [PATCH 05/11] Bump Clap dependency The usage within the library was not compatible with the version listed in Cargo.toml. So I updated, and reworked the code to the current Clap --- server/Cargo.toml | 2 +- server/src/bin.rs | 2 +- server/src/network.rs | 2 +- server/src/options.rs | 8 +++++--- 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/server/Cargo.toml b/server/Cargo.toml index 263d002..bf7a761 100644 --- a/server/Cargo.toml +++ b/server/Cargo.toml @@ -26,6 +26,6 @@ async-trait = "0.1.36" anyhow = "1.0.31" prost = "0.6.1" hex = "0.4" -clap = "3.0.0-beta.1" +clap = { version = "4.5.4", features = ["derive"] } dirs = "3.0.1" async-signals = "0.3.1" diff --git a/server/src/bin.rs b/server/src/bin.rs index e78afde..6bda1a7 100644 --- a/server/src/bin.rs +++ b/server/src/bin.rs @@ -1,5 +1,5 @@ use async_std::task; -use clap::Clap; +use clap::Parser; use hyperspace_server::{listen, run_bootstrap_node, Opts}; fn main() -> anyhow::Result<()> { diff --git a/server/src/network.rs b/server/src/network.rs index ec87d8e..861b1a2 100644 --- a/server/src/network.rs +++ b/server/src/network.rs @@ -42,7 +42,7 @@ pub async fn run(mut replicator: Replicator, opts: Opts) -> io::Result<()> { async fn swarm_config_from_opts(opts: Opts) -> io::Result { let config = Config::default(); let config = if opts.bootstrap.len() > 0 { - config.set_bootstrap_nodes(opts.bootstrap[..].to_vec()) + config.set_bootstrap_nodes(&opts.bootstrap[..].to_vec()) } else { config }; diff --git a/server/src/options.rs b/server/src/options.rs index 2f3d712..d4f76d4 100644 --- a/server/src/options.rs +++ b/server/src/options.rs @@ -1,9 +1,10 @@ -use clap::Clap; +use clap::Parser; use std::net::SocketAddr; use std::path::PathBuf; /// Options for the storage daemon -#[derive(Clap, Debug)] +#[derive(Parser, Debug)] +#[command(version, about, long_about = None)] pub struct Opts { /// Set storage path /// @@ -35,7 +36,8 @@ pub struct Opts { pub dht: bool, /// A level of verbosity, and can be used multiple times - #[clap(short, long, parse(from_occurrences))] + //#[clap(short, long, parse(from_occurrences))] // FIXME maybe + #[clap(short, long)] pub verbose: i32, } From 02e926cd294bf3484f1f605ec9a59dab6b2b407f Mon Sep 17 00:00:00 2001 From: Blake Griffith Date: Thu, 4 Apr 2024 12:15:05 -0500 Subject: [PATCH 06/11] rm '-h' form of host args bc collides with --help --- client/src/bin.rs | 2 +- server/src/options.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/client/src/bin.rs b/client/src/bin.rs index 1d79b59..647300b 100644 --- a/client/src/bin.rs +++ b/client/src/bin.rs @@ -36,7 +36,7 @@ pub struct Opts { pub name: Option, /// Override socket name to connect to - #[arg(short, long)] + #[arg(long)] pub host: Option, #[command(subcommand)] diff --git a/server/src/options.rs b/server/src/options.rs index d4f76d4..7307cbb 100644 --- a/server/src/options.rs +++ b/server/src/options.rs @@ -16,7 +16,7 @@ pub struct Opts { /// /// The actual socket will be created at tmpdir/[host].sock /// Defaults to "hyperspace". - #[clap(short, long)] + #[clap(long)] pub host: Option, /// Address to which Hyperswarm binds From c3c4f4734a089ababa65c408e14ff32a8efb4baf Mon Sep 17 00:00:00 2001 From: Blake Griffith Date: Thu, 4 Apr 2024 12:15:36 -0500 Subject: [PATCH 07/11] allow(dead_code) to silence warnings I'm new to codebase so I don't feel comfortable removing these yet --- replicator/src/peer.rs | 1 + server/src/lib.rs | 1 + 2 files changed, 2 insertions(+) diff --git a/replicator/src/peer.rs b/replicator/src/peer.rs index b21046d..61688f3 100644 --- a/replicator/src/peer.rs +++ b/replicator/src/peer.rs @@ -73,6 +73,7 @@ pub struct Peer { #[derive(Debug, Default, Clone)] pub struct Stats { + #[allow(dead_code)] id: RemotePublicKey, downloaded_blocks: u64, downloaded_bytes: u64, diff --git a/server/src/lib.rs b/server/src/lib.rs index a535ac1..b8cea48 100644 --- a/server/src/lib.rs +++ b/server/src/lib.rs @@ -17,6 +17,7 @@ const STORAGE_DIR: &str = ".hyperspace-rs"; #[derive(Clone)] pub struct State { corestore: Corestore, + #[allow(dead_code)] replicator: Replicator, } From e5e20613c64a22eb87dd3f7a3b495e9e5fed5dd5 Mon Sep 17 00:00:00 2001 From: Blake Griffith Date: Thu, 4 Apr 2024 12:16:20 -0500 Subject: [PATCH 08/11] remove unneeded semicolon --- server/src/network.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/src/network.rs b/server/src/network.rs index 861b1a2..6d2a886 100644 --- a/server/src/network.rs +++ b/server/src/network.rs @@ -14,7 +14,7 @@ pub async fn run(mut replicator: Replicator, opts: Opts) -> io::Result<()> { enum Event { Replicator(ReplicatorEvent), Swarm(io::Result), - }; + } let mut events = replicator_events .map(Event::Replicator) From 2ae28e85040d42501f79ca07cc13bd2500ac9446 Mon Sep 17 00:00:00 2001 From: Blake Griffith Date: Thu, 4 Apr 2024 12:17:45 -0500 Subject: [PATCH 09/11] Remove unused and broken verbose field --- server/src/options.rs | 6 ------ 1 file changed, 6 deletions(-) diff --git a/server/src/options.rs b/server/src/options.rs index 7307cbb..03f1d42 100644 --- a/server/src/options.rs +++ b/server/src/options.rs @@ -34,11 +34,6 @@ pub struct Opts { /// Run a local bootstrapping dht node #[clap(long)] pub dht: bool, - - /// A level of verbosity, and can be used multiple times - //#[clap(short, long, parse(from_occurrences))] // FIXME maybe - #[clap(short, long)] - pub verbose: i32, } impl Default for Opts { @@ -50,7 +45,6 @@ impl Default for Opts { bootstrap: vec![], port: None, dht: false, - verbose: 0, } } } From 86e2acbcc3e73120a38ea5125f9d842051fb812a Mon Sep 17 00:00:00 2001 From: Blake Griffith Date: Thu, 4 Apr 2024 12:18:16 -0500 Subject: [PATCH 10/11] Update README.md example to work with new args Please enter the commit message for your changes. Lines starting --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 6004001..b5b1302 100644 --- a/README.md +++ b/README.md @@ -33,18 +33,18 @@ This example starts two `hyperspace-server` instances and runs a hyperswarm DHT cargo run --bin hyperspace-server -- --dht -a 127.0.0.1:3401 # 2. Start server 1 -cargo run --bin hyperspace-server -- -s /tmp/hs1 -h hs1 -b 127.0.0.1:3401 +cargo run --bin hyperspace-server -- -s /tmp/hs1 --host hs1 -b 127.0.0.1:3401 # 3. Start server 2 -cargo run --bin hyperspace-server -- -s /tmp/hs2 -h hs2 -b 127.0.0.1:3401 +cargo run --bin hyperspace-server -- -s /tmp/hs2 --host hs2 -b 127.0.0.1:3401 # 4. Write to a feed on server 1 -cargo run --bin hyperspace-client -- -h hs1 -n afeed write +cargo run --bin hyperspace-client -- --host hs1 -n afeed write # the feed's key will be printed # (type something and press enter, it will be appended to the feed) # 5. Read from the feed from server 2 -cargo run --bin hyperspace-client -- -h hs2 -k KEY_FROM_ABOVE read +cargo run --bin hyperspace-client -- --host hs2 -k KEY_FROM_ABOVE read ``` ### Contributing From b657697190dbb83a24955825603d5606e313705e Mon Sep 17 00:00:00 2001 From: Blake Griffith Date: Thu, 4 Apr 2024 12:23:18 -0500 Subject: [PATCH 11/11] rm unused hypercore-protocol cargo patch --- Cargo.toml | 1 - 1 file changed, 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 3c67d53..964921f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,7 +3,6 @@ members = ["client","server", "common", "corestore", "replicator"] [patch.crates-io] hypercore = { git = "https://github.com/Frando/datrs-hypercore", branch = "hyperspace" } -hypercore-protocol = { git = "https://github.com/Frando/hypercore-protocol-rs", branch = "reduce-async" } libutp-sys = { git = "https://github.com/cowlicks/libutp-sys.git", branch = "fix-build-failure", optional = true } # hrpc = { path = "../hrpc" }