Expand description
A client to retrieve the current Mithril era.
In order to do so it defines a MithrilEraClient which exposes the following features:
- fetch_current: fetch the current Mithril era using its EraFetcher
This module defines the following components:
- EraFetcher: defines an interface to retrieve the current Mithril era
- AggregatorHttpEraFetcher: an implementation of EraFetcher using an HTTP call to the aggregator
- 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§
- Aggregator
Http EraFetcher - An implementation of EraFetcher that retrieves the current Mithril era
by performing an HTTP request to the aggregator’s
/status
endpoint. - Fetched
Era - Wrapper around a raw Mithril era string.
- Mithril
EraClient - Client for retrieving the current Mithril era.
Traits§
- EraFetcher
- Trait for retrieving the current Mithril era.