mithril_client

Module cardano_stake_distribution_client

source
Expand description

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

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

  • get: get a Cardano stake distribution data from its hash
  • get_by_epoch: get a Cardano stake distribution data from its epoch
  • list: get the list of available Cardano stake distribution

§Get a Cardano stake distribution

To get a Cardano stake distribution using the ClientBuilder.

use mithril_client::ClientBuilder;

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

println!(
    "Cardano stake distribution hash={}, epoch={}, stake_distribution={:?}",
    cardano_stake_distribution.hash,
    cardano_stake_distribution.epoch,
    cardano_stake_distribution.stake_distribution
);

§List available Cardano stake distributions

To list available Cardano stake distributions using the ClientBuilder.

use mithril_client::ClientBuilder;

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

for cardano_stake_distribution in cardano_stake_distributions {
    println!("Cardano stake distribution hash={}, epoch={}", cardano_stake_distribution.hash, cardano_stake_distribution.epoch);
}

§Get a Cardano stake distribution by epoch

To get a Cardano stake distribution by epoch using the ClientBuilder. The epoch represents the epoch at the end of which the Cardano stake distribution is computed by the Cardano node

use mithril_client::ClientBuilder;
use mithril_client::common::Epoch;

let client = ClientBuilder::aggregator("YOUR_AGGREGATOR_ENDPOINT", "YOUR_GENESIS_VERIFICATION_KEY").build()?;
let cardano_stake_distribution = client.cardano_stake_distribution().get_by_epoch(Epoch(500)).await?.unwrap();

println!(
    "Cardano stake distribution hash={}, epoch={}, stake_distribution={:?}",
    cardano_stake_distribution.hash,
    cardano_stake_distribution.epoch,
    cardano_stake_distribution.stake_distribution
);

Structs§