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§
- encoding
- Hypercore-specific compact encodings
- prelude
- Convenience wrapper to import all of Hypercore’s core.
- replication
- Hypercore to Hypercore replication
Structs§
- Append
Outcome - Response from append, matches that of the Javascript result
- Cache
Options Builder - Build CacheOptions.
- Hypercore
- Hypercore is an append-only log structure.
- Hypercore
Builder - Build a Hypercore instance with options.
- Info
- Info about the hypercore
- Partial
Keypair - Key pair where for read-only hypercores the secret key can also be missing.
- Signature
- Ed25519 signature.
- Signing
Key - ed25519 signing key which can be used to produce signatures.
- Storage
- Save data to a desired storage backend.
- Verifying
Key - An ed25519 public key.
Enums§
- Hypercore
Error - Common error type for the hypercore interface
- Store
- The types of stores that can be created.
Constants§
- KEYPAIR_
LENGTH - The length of an ed25519
Keypair, in bytes. - PUBLIC_
KEY_ LENGTH - The length of an ed25519
PublicKey, in bytes. - SECRET_
KEY_ LENGTH - The length of a ed25519
SecretKey, in bytes.
Traits§
- Storage
Traits - Supertrait for Storage
Functions§
- generate_
signing_ key - Generate a new
Ed25519key pair. - sign
- Sign a byte slice using a keypair’s private key.
- verify
- Verify a signature on a message with a keypair’s public key.
Type Aliases§
- Secret
Key - ed25519 secret key as defined in RFC8032 § 5.1.5: