An exploration towards a Rust daemon for Hypercore storage and replication.
This repo contains a few different crates that together work towards an implementation of the hyperspace server (orignally written in Node.js). Hyperspace is a small server that stores and manages Hypercores, and can replicate Hypercores to peers found over the Hyperswarm distributed hash table.
All are still work in progress and in many parts unfinished.
- hyperspace-server: Runs a Hypercore storage and networking daemon that can be talked with over an RPC socket through hrpc. Library and binary
- hyperspace-client: A client that talks with a hyperspace server over hrpc and exposes a
RemoteCorestore. Libray and binary
- corestore: Manage storage for hypercores. A port of corestore. Library
- hypercore-replicator: Replicate Hypercores with hypercore-protocol. Manages channels for many feeds and peer connections. Library
- hyperspace-common: Modules shared between server and client. RPC codegen, utilities. Library
Note: None of these crates are published on crates.io yet
- The modules here use a Hypercore branch with two unmerged PRs that add an event emitter and remove the generic type argument on the
- The hyperswarm-dht, which the hyperswarm-server uses, is work in progress and may still break public API
- hrpc is not yet published on crates.io because it depends on an unmerged PR in prost
This example starts two
hyperspace-server instances and runs a hyperswarm DHT node on localhost. It then uses
hyperspace-client to create and append a hypercore on the first instance. Then, again with
hyperspace-client, the same feed is requested from the second server instance, which should replicate it because the two servers find each other over the localhost DHT. All in Rust, no Node involved!
# The commands need to be run in seperate terminals each. # 1. Start a DHT node 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 # 3. Start server 2 cargo run --bin hyperspace-server -- -s /tmp/hs2 -h 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 # 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
This project, even though in early stages, is very open to contributions. If unsure, please find us in #datrs on IRC or open an issue first.