Crate hypercore

source ·
Expand description

Introduction

Hypercore is a secure, distributed append-only log. Built for sharing large datasets and streams of real time data as part of the Dat project. This is a rust port of the original Javascript version aiming for interoperability with LTS version. The primary way to use this crate is through the Hypercore struct, which can be created using the HypercoreBuilder.

This crate supports WASM with cargo build --target=wasm32-unknown-unknown.

Features

sparse (default)

When using disk storage, clearing values may create sparse files. On by default.

async-std (default)

Use the async-std runtime, on by default. Either this or tokio is mandatory.

tokio

Use the tokio runtime. Either this or async_std is mandatory.

cache

Use a moka cache for merkle tree nodes to speed-up reading.

Example

use hypercore::{HypercoreBuilder, Storage};

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

Modules

  • Hypercore-specific compact encodings
  • Convenience wrapper to import all of Hypercore’s core.

Structs

Enums

  • Common error type for the hypercore interface
  • The types of stores that can be created.

Constants

Functions

  • Generate a new Ed25519 key pair.
  • Sign a byte slice using a keypair’s private key.
  • Verify a signature on a message with a keypair’s public key.

Type Aliases