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: download and unpack the tarball of a snapshot to a directory
§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.snapshot().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.snapshot().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 snapshots 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.snapshot().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
.snapshot()
.download_unpack(&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.snapshot().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
.snapshot()
.download_unpack(&snapshot, target_directory)
.await?;
client.snapshot().add_statistics(&snapshot).await.unwrap();
Structs§
- Aggregator client for the snapshot artifact
Enums§
- Error for the Snapshot client