Module era

Module era 

Source
Expand description

A client to retrieve the current Mithril era.

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

This module defines the following components:

  • EraFetcher: defines an interface to retrieve the current Mithril era, an implementation over [mithril_aggregator_client::AggregatorHttpClient] is provided
  • FetchedEra: a wrapper around a raw era string that provides a conversion to SupportedEra

§Retrieve the current Mithril era

To get SupportedEra using the ClientBuilder.

use mithril_client::ClientBuilder;

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

let fetched_era = client.mithril_era_client().fetch_current().await?;
match fetched_era.to_supported_era() {
    Ok(supported_era) => println!("Current Mithril era: {supported_era}"),
    Err(era) => println!(
        "Warning: Unsupported era '{}', the aggregator might not be compatible with this client version. Consider upgrading.\nFetched era: {era}",
        fetched_era.era
    ),
}

Structs§

FetchedEra
Wrapper around a raw Mithril era string.
MithrilEraClient
Client for retrieving the current Mithril era.

Traits§

EraFetcher
Trait for retrieving the current Mithril era.