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, download tarball and record statistics.
- Mithril stake distribution list and get.
- Cardano transactions list & get snapshot, get proofs.
- Cardano stake distribution list, get and get by epoch.
- 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?;
if let Err(e) = client.snapshot().add_statistics(&snapshot).await {
println!("Could not increment snapshot download statistics: {:?}", e);
}
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 to retrieve Cardano stake distributions data from an Aggregator.
- A client to retrieve from an aggregator cryptographic proofs of membership for a subset of Cardano transactions.
- 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§
- A Cardano stake distribution. Message structure of a Cardano Stake Distribution
- List item of Cardano stake distributions. Message structure of a Cardano Stake Distribution list item
- A snapshot that allow to know up to which point of time Mithril have certified Cardano transactions. Message structure of a Cardano Transactions snapshot
- List item of a Cardano transaction snapshot. Message structure of a Cardano Transactions Snapshot list item
- A cryptographic proof for a set of Cardano transactions
- A cryptographic proof of a set of Cardano transactions is included in the global Cardano transactions set
- 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.
- Options that can be used to configure the client.
- 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
- Set of transactions verified by CardanoTransactionsProofsMessage::verify.
Enums§
- Error encountered or produced by the cardano transaction proof verification.
Type Aliases§
- Mithril error type, an alias of anyhow::Error
- Mithril result type, an alias of anyhow::Result