Expand description
A client to retrieve snapshots data from an Aggregator.
In order to do so it defines a SnapshotClient which exposes the following features:
- get: get a single snapshot data from its digest
- list: get the list of available snapshots
- download_unpack_full: download and unpack the tarball of a snapshot and its ancillary files to a directory, use this function if you want to fast bootstrap a Cardano node
- download_unpack: download and unpack the tarball of a snapshot to a directory (immutable files only)
Note: Ancillary files are the files that are not signed by Mithril but are needed to enable fast They include the last ledger state snapshot and the last immutable file.
§Get a single snapshot
To get a single snapshot using the ClientBuilder.
use mithril_client::ClientBuilder;
let client = ClientBuilder::aggregator("YOUR_AGGREGATOR_ENDPOINT", "YOUR_GENESIS_VERIFICATION_KEY").build()?;
let snapshot = client.cardano_database().get("SNAPSHOT_DIGEST").await?.unwrap();
println!("Snapshot digest={}, size={}", snapshot.digest, snapshot.size);
§List available snapshots
To list available snapshots using the ClientBuilder.
use mithril_client::ClientBuilder;
let client = ClientBuilder::aggregator("YOUR_AGGREGATOR_ENDPOINT", "YOUR_GENESIS_VERIFICATION_KEY").build()?;
let snapshots = client.cardano_database().list().await?;
for snapshot in snapshots {
println!("Snapshot digest={}, size={}", snapshot.digest, snapshot.size);
}
§Download a snapshot
Note: Available on crate feature fs only.
To download and simultaneously unpack the tarball of a snapshot using the ClientBuilder , including its ancillary files, to a directory.
use mithril_client::ClientBuilder;
use std::path::Path;
let client = ClientBuilder::aggregator("YOUR_AGGREGATOR_ENDPOINT", "YOUR_GENESIS_VERIFICATION_KEY")
.set_ancillary_verification_key("YOUR_ANCILLARY_VERIFICATION_KEY".to_string())
.build()?;
let snapshot = client.cardano_database().get("SNAPSHOT_DIGEST").await?.unwrap();
// Note: the directory must already exist, and the user running the binary must have read/write access to it.
let target_directory = Path::new("/home/user/download/");
client
.cardano_database()
.download_unpack_full(&snapshot, target_directory)
.await?;
§Add statistics
Note: Available on crate feature fs only.
Increments the aggregator snapshot download statistics using the ClientBuilder.
use mithril_client::ClientBuilder;
use std::path::Path;
let client = ClientBuilder::aggregator("YOUR_AGGREGATOR_ENDPOINT", "YOUR_GENESIS_VERIFICATION_KEY").build()?;
let snapshot = client.cardano_database().get("SNAPSHOT_DIGEST").await?.unwrap();
// Note: the directory must already exist, and the user running the binary must have read/write access to it.
let target_directory = Path::new("/home/user/download/");
client
.cardano_database()
.download_unpack(&snapshot, target_directory)
.await?;
client.snapshot().add_statistics(&snapshot).await.unwrap();
Structs§
- Snapshot
Client - Aggregator client for the snapshot artifact
Enums§
- Snapshot
Client Error - Error for the Snapshot client