Skip to content
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
[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" }
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.
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion client/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"] }
15 changes: 8 additions & 7 deletions client/src/bin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand All @@ -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<String>,
/// Hypercore name
#[clap(short, long)]
#[arg(short, long)]
pub name: Option<String>,

/// Override socket name to connect to
#[clap(short, long)]
#[arg(long)]
pub host: Option<String>,

#[clap(subcommand)]
#[command(subcommand)]
pub command: Command,
}

#[derive(Clap, Debug)]
#[derive(Subcommand, Debug)]
pub enum Command {
/// Read from a Hypercore
Read,
Expand Down
3 changes: 2 additions & 1 deletion replicator/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
1 change: 1 addition & 0 deletions replicator/src/peer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion server/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
2 changes: 1 addition & 1 deletion server/src/bin.rs
Original file line number Diff line number Diff line change
@@ -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<()> {
Expand Down
1 change: 1 addition & 0 deletions server/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ const STORAGE_DIR: &str = ".hyperspace-rs";
#[derive(Clone)]
pub struct State {
corestore: Corestore,
#[allow(dead_code)]
replicator: Replicator,
}

Expand Down
4 changes: 2 additions & 2 deletions server/src/network.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ pub async fn run(mut replicator: Replicator, opts: Opts) -> io::Result<()> {
enum Event {
Replicator(ReplicatorEvent),
Swarm(io::Result<HyperswarmStream>),
};
}

let mut events = replicator_events
.map(Event::Replicator)
Expand Down Expand Up @@ -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<Config> {
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
};
Expand Down
12 changes: 4 additions & 8 deletions server/src/options.rs
Original file line number Diff line number Diff line change
@@ -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
///
Expand All @@ -15,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<String>,

/// Address to which Hyperswarm binds
Expand All @@ -33,10 +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))]
pub verbose: i32,
}

impl Default for Opts {
Expand All @@ -48,7 +45,6 @@ impl Default for Opts {
bootstrap: vec![],
port: None,
dht: false,
verbose: 0,
}
}
}