Skip to main content

FetchCurrent

Trait FetchCurrent 

Source
pub trait FetchCurrent: Sized {
    // Required methods
    fn fetch_current<'life0, 'async_trait>(
        sdk: &'life0 Sdk,
    ) -> Pin<Box<dyn Future<Output = Result<Self, Error>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn fetch_current_with_metadata<'life0, 'async_trait>(
        sdk: &'life0 Sdk,
    ) -> Pin<Box<dyn Future<Output = Result<(Self, ResponseMetadata), Error>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn fetch_current_with_metadata_and_proof<'life0, 'async_trait>(
        sdk: &'life0 Sdk,
    ) -> Pin<Box<dyn Future<Output = Result<(Self, ResponseMetadata, Proof), Error>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
}
Expand description

Helper trait for fetching current state from Platform without query parameters.

Implemented for types that have a single “current” value on Platform, such as the current epoch (ExtendedEpochInfo) or total credits in platform.

Required Methods§

Source

fn fetch_current<'life0, 'async_trait>( sdk: &'life0 Sdk, ) -> Pin<Box<dyn Future<Output = Result<Self, Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Fetch the current value from Platform.

Source

fn fetch_current_with_metadata<'life0, 'async_trait>( sdk: &'life0 Sdk, ) -> Pin<Box<dyn Future<Output = Result<(Self, ResponseMetadata), Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Fetch the current value from Platform with metadata.

Source

fn fetch_current_with_metadata_and_proof<'life0, 'async_trait>( sdk: &'life0 Sdk, ) -> Pin<Box<dyn Future<Output = Result<(Self, ResponseMetadata, Proof), Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Fetch the current value from Platform with metadata and proof.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl FetchCurrent for ExtendedEpochInfo

Source§

fn fetch_current<'life0, 'async_trait>( sdk: &'life0 Sdk, ) -> Pin<Box<dyn Future<Output = Result<Self, Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Fetch the current epoch.

See fetch_current_with_metadata_and_proof for how the current epoch is selected and authenticated.

Source§

fn fetch_current_with_metadata<'life0, 'async_trait>( sdk: &'life0 Sdk, ) -> Pin<Box<dyn Future<Output = Result<(Self, ResponseMetadata), Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Fetch the current epoch together with the metadata of the response that authenticated it.

See fetch_current_with_metadata_and_proof for how the current epoch is selected and authenticated.

Source§

fn fetch_current_with_metadata_and_proof<'life0, 'async_trait>( sdk: &'life0 Sdk, ) -> Pin<Box<dyn Future<Output = Result<(Self, ResponseMetadata, Proof), Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Fetch the current epoch together with the metadata and proof that authenticated it.

§Why this takes two queries

The proof verifier rejects proved descending epoch queries without an explicit start epoch: resolving “the last epoch” server-side would force verification to trust unsigned response metadata. An explicit descending start does not help by itself either — Drive pre-creates thousands of empty epoch trees above the current one, and a proved descending query starting inside that window provably returns nothing (the query limit is consumed by the empty trees).

So the fetch is done in two proved, guard-compliant steps:

  1. Probe: fetch the genesis epoch (explicit ascending start), and take the current-epoch hint from the response metadata.
  2. Confirm: fetch two epochs ascending from the hint. Drive stores epoch n + 1 as an empty tree until epoch n + 1 starts, and an empty tree consumes query limit without contributing elements — so a single-epoch result is proof that the hint is the newest started epoch.
§What is authenticated

The metadata hint only shapes the second request; it is never trusted as an answer. The returned epoch and the absence of any epoch above it both come from the same quorum-signed GroveDB proof:

  • A hint above the current epoch lands in the pre-created empty window and provably matches nothing — Error::EpochNotFound.
  • A hint below the current epoch is contradicted by the node’s own proof, which then carries the newer epoch. The query is repeated from that proven index (up to [MAX_CURRENT_EPOCH_REFINEMENTS] times, enough for an epoch that turns over mid-fetch) and otherwise fails closed with StaleNodeError::Epoch.

The returned proof is the one from the confirming query, so it covers both the epoch itself and the evidence that no later epoch has started.

Implementors§