Crate mithril_client
source ·Expand description
Define all the tooling necessary to manipulate Mithril certified types from a Mithril Aggregator.
It handles the different types that can be queried to a Mithril aggregator:
- Snapshot list, get and download tarball.
- Mithril stake distribution list and get.
- Certificates list, get, and chain validation.
The Client aggregates the queries of all of those types.
NOTE: Snapshot download and Certificate chain validation can take quite some time even with a fast computer and network. For those a feedback mechanism is available, more details on it in the feedback submodule.
Example
Below is an example describing the usage of most of the library’s functions together:
Note: Snapshot download and the compute snapshot message functions are available using crate feature fs.
use mithril_client::{ClientBuilder, MessageBuilder};
use std::path::Path;
let client = ClientBuilder::aggregator("YOUR_AGGREGATOR_ENDPOINT", "YOUR_GENESIS_VERIFICATION_KEY").build()?;
let snapshots = client.snapshot().list().await?;
let last_digest = snapshots.first().unwrap().digest.as_ref();
let snapshot = client.snapshot().get(last_digest).await?.unwrap();
let certificate = client
.certificate()
.verify_chain(&snapshot.certificate_hash)
.await?;
// 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?;
let message = MessageBuilder::new()
.compute_snapshot_message(&certificate, &target_directory)
.await?;
assert!(certificate.match_message(&message));
Modules
- Mechanisms to exchange data with an Aggregator.
- A client which retrieves and validates certificates from an Aggregator.
mithril-common
re-exports- Long task feedbacks
- A client to retrieve Mithril stake distributions data from an Aggregator.
- A client to retrieve snapshots data from an Aggregator.
- Snapshot tarball download and unpack mechanism.
Structs
- Structure that aggregates the available clients for each of the Mithril types of certified data.
- Builder than can be used to create a Client easily or with custom dependencies.
- A MessageBuilder can be used to compute the message of Mithril artifacts.
- A Mithril certificate.
- List item of Mithril certificates
- CertificateListItemMessage represents the metadata associated to a CertificateListItemMessage
- CertificateMetadata represents the metadata associated to a Certificate
- An individual signer of a Mithril certificate
- A Mithril stake distribution.
- List item of Mithril stake distributions.
- A Mithril snapshot of a Cardano Node database.
- List item of Mithril snapshots
Type Aliases
- Mithril error type, an alias of anyhow::Error
- Mithril result type, an alias of anyhow::Result