Trait MainchainEpochDerivation

Source
pub trait MainchainEpochDerivation {
    // Required methods
    fn epochs_passed(
        &self,
        timestamp: Timestamp,
    ) -> Result<u32, EpochDerivationError>;
    fn timestamp_to_mainchain_epoch(
        &self,
        timestamp: Timestamp,
    ) -> Result<McEpochNumber, EpochDerivationError>;
    fn timestamp_to_mainchain_slot_number(
        &self,
        timestamp: Timestamp,
    ) -> Result<u64, EpochDerivationError>;
    fn mainchain_epoch_to_timestamp(&self, epoch: McEpochNumber) -> Timestamp;
    fn first_slot_of_epoch(
        &self,
        epoch: McEpochNumber,
    ) -> Result<McSlotNumber, EpochDerivationError>;
    fn epoch_for_slot(
        &self,
        slot: McSlotNumber,
    ) -> Result<McEpochNumber, EpochDerivationError>;
}
Expand description

Functions for performing calculations on Cardano epoch and slot numbers

Required Methods§

Source

fn epochs_passed( &self, timestamp: Timestamp, ) -> Result<u32, EpochDerivationError>

Calculates the number of Cardano epochs passed since the first Shelley epoch up to timestamp

Source

fn timestamp_to_mainchain_epoch( &self, timestamp: Timestamp, ) -> Result<McEpochNumber, EpochDerivationError>

Calculates the number of the Cardano epoch containing timestamp

Source

fn timestamp_to_mainchain_slot_number( &self, timestamp: Timestamp, ) -> Result<u64, EpochDerivationError>

Calculates the number of the Cardano slot containing timestamp

Source

fn mainchain_epoch_to_timestamp(&self, epoch: McEpochNumber) -> Timestamp

Calculates the starting time of the Cardano epoch

Source

fn first_slot_of_epoch( &self, epoch: McEpochNumber, ) -> Result<McSlotNumber, EpochDerivationError>

Calculates the slot number of the first Cardano slot of given epoch

Source

fn epoch_for_slot( &self, slot: McSlotNumber, ) -> Result<McEpochNumber, EpochDerivationError>

Calculates the number of the Cardano epoch containing slot

Implementors§