mithril_client

Module mithril_stake_distribution_client

source
Expand description

A client to retrieve Mithril stake distributions data from an Aggregator.

In order to do so it defines a MithrilStakeDistributionClient which exposes the following features:

  • get: get a Mithril stake distribution data from its hash
  • list: get the list of available Mithril stake distribution

§Get a Mithril stake distribution

To get a Mithril stake distribution using the ClientBuilder.

use mithril_client::ClientBuilder;

let client = ClientBuilder::aggregator("YOUR_AGGREGATOR_ENDPOINT", "YOUR_GENESIS_VERIFICATION_KEY").build()?;
let mithril_stake_distribution = client.mithril_stake_distribution().get("MITHRIL_STAKE_DISTRIBUTION_HASH").await?.unwrap();

println!("Mithril stake distribution hash={}, epoch={}", mithril_stake_distribution.hash, mithril_stake_distribution.epoch);

§List available Mithril stake distributions

To list available Mithril stake distributions using the ClientBuilder.

use mithril_client::ClientBuilder;

let client = ClientBuilder::aggregator("YOUR_AGGREGATOR_ENDPOINT", "YOUR_GENESIS_VERIFICATION_KEY").build()?;
let mithril_stake_distributions = client.mithril_stake_distribution().list().await?;

for mithril_stake_distribution in mithril_stake_distributions {
    println!("Mithril stake distribution hash={}, epoch={}", mithril_stake_distribution.hash, mithril_stake_distribution.epoch);
}

Structs§