Hypercore is a secure, distributed append-only log. This crate is a limited Rust port of the original Javascript holepunchto/hypercore. The goal is to maintain binary compatibility with the LTS version with regards to disk storage.
See hypercore-protocol-rs for the corresponding wire protocol implementation.
tokio
or async-std
runtimes// Create an in-memory hypercore using a builder
let mut hypercore = HypercoreBuilder::new(Storage::new_memory().await.unwrap())
.build()
.await
.unwrap();
// Append entries to the log
hypercore.append(b"Hello, ").await.unwrap();
hypercore.append(b"world!").await.unwrap();
// Read entries from the log
assert_eq!(hypercore.get(0).await.unwrap().unwrap(), b"Hello, ");
assert_eq!(hypercore.get(1).await.unwrap().unwrap(), b"world!");
Find more examples in the examples folder, and/or run:
cargo run --example memory
cargo run --example disk
cargo run --example replication
cargo add hypercore
This crate uses #![forbid(unsafe_code)]
to ensure everythong is implemented in
100% Safe Rust.
To test interoperability with Javascript, enable the js_interop_tests
feature:
cargo test --features js_interop_tests
Run benches with:
cargo bench
Want to join us? Check out our "Contributing" guide and take a look at some of these issues:
MIT OR Apache-2.0