EraFileId

Trait EraFileId 

Source
pub trait EraFileId: Clone {
    const FILE_TYPE: EraFileType;
    const ITEMS_PER_ERA: u64;

    // Required methods
    fn network_name(&self) -> &str;
    fn start_number(&self) -> u64;
    fn count(&self) -> u32;
    fn hash(&self) -> Option<[u8; 4]>;
    fn include_era_count(&self) -> bool;

    // Provided methods
    fn era_number(&self) -> u64 { ... }
    fn era_count(&self) -> u64 { ... }
    fn to_file_name(&self) -> String { ... }
}
Expand description

Era file identifiers

Required Associated Constants§

Source

const FILE_TYPE: EraFileType

File type for this identifier

Source

const ITEMS_PER_ERA: u64

Number of items, slots for era, blocks for era1, per era

Required Methods§

Source

fn network_name(&self) -> &str

Get the network name

Source

fn start_number(&self) -> u64

Get the starting number (block or slot)

Source

fn count(&self) -> u32

Get the count of items

Source

fn hash(&self) -> Option<[u8; 4]>

Get the optional hash identifier

Source

fn include_era_count(&self) -> bool

Whether to include era count in filename

Provided Methods§

Source

fn era_number(&self) -> u64

Calculate era number

Source

fn era_count(&self) -> u64

Calculate the number of eras spanned per file.

If the user can decide how many slots/blocks per era file there are, we need to calculate it. Most of the time it should be 1, but it can never be more than 2 eras per file as there is a maximum of 8192 slots/blocks per era file.

Source

fn to_file_name(&self) -> String

Convert to standardized file name.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl EraFileId for Era1Id

Source§

const FILE_TYPE: EraFileType = EraFileType::Era1

Source§

const ITEMS_PER_ERA: u64 = 8_192u64

Source§

impl EraFileId for EraId

Source§

const FILE_TYPE: EraFileType = EraFileType::Era

Source§

const ITEMS_PER_ERA: u64 = 8_192u64