MCPcopy Index your code
hub / github.com/datrs/hypercore-protocol-rs

github.com/datrs/hypercore-protocol-rs @v0.6.1

Chat with this repo
repository ↗ · DeepWiki ↗ · release v0.6.1 ↗ · + Follow
314 symbols 689 edges 25 files 60 documented · 19%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

Hypercore Protocol

crates.io version build status downloads docs.rs docs

Hypercore protocol is a streaming, message based protocol. This is a Rust port of the wire protocol implementation in the original Javascript version. This crate targets the Hypercore LTS version 10.

This crate provides a low-level streaming API to hypercore-protocol and exposes an interface that should make it easy to implement actual protocol logic on top.

This crate uses either async-std or tokio for async IO, snow for the Noise handshake and RustCrypto's crypto_secretsteram for encryption.

Features

  • [x] Complete the Noise handshake
  • [x] Establish libsodium's crypto_secretstream.
  • [x] Open channels with a key
  • [x] Accept channels opened by the remote end if your end knows the key
  • [x] Create and verify capability hashes
  • [x] Send and receive all protocol messages
  • [x] Support async-std or tokio runtimes
  • [x] Support WASM
  • [x] Test Javascript interoperability
  • [ ] Support the new manifest in the wire protocol to remain compatible with upcoming v11
  • [ ] Finalize documentation and release v1.0.0

Installation

cargo add hypercore-protocol

Examples

These examples sync data between Rust and NodeJS hypercore-protocol implementations. To prepare, run

cd examples-nodejs && npm install && cd ..

replication.rs

Runs the replication.rs example by replicating a hypercore between Rust and Node hypercores and printing the result.

  • Node Server / Rust Client
node examples-nodejs/run.js nodeServer
  • Rust Server / Node Client
node examples-nodejs/run.js rustServer
  • Rust Server / Rust Client
node examples-nodejs/run.js rust
  • Node Server / Node Client
node examples-nodejs/run.js node

Development

To test interoperability with Javascript, enable the js_interop_tests feature:

cargo test --features js_interop_tests

Run benches with:

cargo bench

Contributing

We're actively looking for contributors to the datrust development! If you're interested, the easiest is to say hi in the #rust channel on the Hypercore Protocol Discord.

Want to help with Hypercore Protocol? Check out our "Contributing" guide and take a look at the open issues.

License

MIT OR Apache-2.0

Extension points exported contracts — how you extend this code

Encoder (Interface)
Encode data into a buffer. This trait is implemented on data frames and their components (channel messages, messages, a [3 …
src/message.rs

Core symbols most depended-on inside this repo

start
called by 25
src/crypto/handshake.rs
send
called by 21
src/protocol.rs
open
called by 14
src/protocol.rs
get
called by 14
examples/replication.rs
lock
called by 12
tests/js/interop.js
queue_event
called by 9
src/protocol.rs
next_event
called by 9
tests/_util.rs
encoded_len
called by 8
src/message.rs

Shape

Method 173
Function 92
Class 40
Enum 8
Interface 1

Languages

Rust94%
TypeScript6%

Modules by API surface

src/channels.rs44 symbols
src/protocol.rs43 symbols
tests/js_interop.rs33 symbols
src/message.rs21 symbols
examples/replication.rs18 symbols
src/schema.rs16 symbols
src/crypto/handshake.rs16 symbols
src/writer.rs14 symbols
src/crypto/curve.rs14 symbols
tests/js/interop.js11 symbols
src/reader.rs10 symbols
src/crypto/cipher.rs10 symbols

For agents

$ claude mcp add hypercore-protocol-rs \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact