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:

§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§

AggregatorHttpEraFetcher
An implementation of EraFetcher that retrieves the current Mithril era by performing an HTTP request to the aggregator’s /status endpoint.
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.