#merkle #p2p #dat #feed #stream

hypercore

Secure, distributed, append-only log

35 releases

0.13.0 Jul 4, 2024
0.12.1 Oct 28, 2023
0.11.1-beta.10 Jul 19, 2020
0.11.1-beta.3 Mar 3, 2020
0.0.0 Mar 30, 2018

#59 in Asynchronous

Download history 95/week @ 2024-03-29 158/week @ 2024-04-05 44/week @ 2024-04-12 8/week @ 2024-04-19 341/week @ 2024-04-26 869/week @ 2024-05-03 807/week @ 2024-05-10 832/week @ 2024-05-17 208/week @ 2024-05-24 192/week @ 2024-05-31 124/week @ 2024-06-07 375/week @ 2024-06-14 292/week @ 2024-06-21 260/week @ 2024-06-28 417/week @ 2024-07-05 369/week @ 2024-07-12

1,540 downloads per month
Used in 5 crates (3 directly)

MIT/Apache

230KB
5.5K SLoC

Hypercore

crates.io version build status downloads docs.rs docs

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.

Features

  • Create in-memory and disk hypercores
  • Append to hypercore either a single entry or a batch of entries
  • Get entries from hypercore
  • Clear range from hypercore, with optional support for sparse files
  • Support basic replication by creating proofs in a source hypercore and verifying and applying them to a destination hypercore
  • Support tokio or async-std runtimes
  • Support WASM for in-memory storage
  • Test Javascript interoperability for supported features
  • Add optional read cache
  • Support the new manifest in the wire protocol to remain compatible with upcoming v11
  • Finalize documentation and release v1.0.0

Usage

// 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

Installation

cargo add hypercore

Safety

This crate uses #![forbid(unsafe_code)] to ensure everythong is implemented in 100% Safe Rust.

Development

To test interoperability with Javascript, enable the js_interop_tests feature:

cargo test --features js_interop_tests

Run benches with:

cargo bench

Contributing

Want to join us? Check out our "Contributing" guide and take a look at some of these issues:

License

MIT OR Apache-2.0

Dependencies

~4–18MB
~241K SLoC