pub struct ProtocolTimelines {
pub genesis_ts: u64,
pub era: NonZeroU64,
pub election: u64,
pub slot: NonZeroU64,
}Expand description
GearExe network timelines configuration. Parameters fetched the Router contract. This struct stores in the database, because of using in the multiple places.
Fields§
§genesis_ts: u64§era: NonZeroU64§election: u64The election duration in seconds before the end of an era when the next set of validators elected. (start of era)[ - - - - - - - - - - - - + - - - - ] (end of era) ^ election
slot: NonZeroU64The slot duration in seconds.
Implementations§
Source§impl ProtocolTimelines
impl ProtocolTimelines
Sourcepub fn block_coordinator_at(
&self,
validators: &ValidatorsVec,
timestamp: u64,
) -> Option<Address>
pub fn block_coordinator_at( &self, validators: &ValidatorsVec, timestamp: u64, ) -> Option<Address>
Calculates the coordinator address for a given Ethereum block timestamp.
The coordinator is the validator picked once per Ethereum block to
aggregate finalized MBs into a BatchCommitment and submit it
on-chain. Block production itself is driven by Malachite — coordinator
election is independent.
§Arguments
validators- A non-empty vector of validator addresses.timestamp- The timestamp for which to calculate the coordinator.
Returns None if timestamp is before genesis.
Sourcepub fn block_coordinator_index_at(
&self,
validators_amount: NonZeroUsize,
timestamp: u64,
) -> Option<usize>
pub fn block_coordinator_index_at( &self, validators_amount: NonZeroUsize, timestamp: u64, ) -> Option<usize>
Calculates the coordinator index for a given Ethereum block timestamp.
§Arguments
validators_amount- The number of validators in the protocol.timestamp- The timestamp for which to calculate the coordinator index.
Returns None if timestamp is before genesis.
Source§impl ProtocolTimelines
impl ProtocolTimelines
Sourcepub fn era_from_ts(&self, ts: u64) -> Option<u64>
pub fn era_from_ts(&self, ts: u64) -> Option<u64>
Returns the era index for the given timestamp. Eras starts from 0.
Returns None if ts < genesis_ts
Sourcepub fn era_start_ts(&self, era_index: u64) -> Option<u64>
pub fn era_start_ts(&self, era_index: u64) -> Option<u64>
Returns the timestamp since which the given era started.
Returns None if overflows u64.
Sourcepub fn era_election_start_ts(&self, era_index: u64) -> Option<u64>
pub fn era_election_start_ts(&self, era_index: u64) -> Option<u64>
Returns the timestamp when election starts in the given era. NOTE: election starts for the next era validators.
Returns None if overflows u64.
§Panics
Panics if era duration < election duration
Sourcepub fn slot_from_ts(&self, ts: u64) -> Option<u64>
pub fn slot_from_ts(&self, ts: u64) -> Option<u64>
Returns the slot index for the given timestamp. Slots starts from 0.
Returns None if ts < genesis_ts
Trait Implementations§
Source§impl Clone for ProtocolTimelines
impl Clone for ProtocolTimelines
Source§fn clone(&self) -> ProtocolTimelines
fn clone(&self) -> ProtocolTimelines
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for ProtocolTimelines
Source§impl Debug for ProtocolTimelines
impl Debug for ProtocolTimelines
Source§impl Decode for ProtocolTimelines
impl Decode for ProtocolTimelines
Source§fn decode<__CodecInputEdqy: Input>(
__codec_input_edqy: &mut __CodecInputEdqy,
) -> Result<Self, Error>
fn decode<__CodecInputEdqy: Input>( __codec_input_edqy: &mut __CodecInputEdqy, ) -> Result<Self, Error>
Source§fn decode_into<I>(
input: &mut I,
dst: &mut MaybeUninit<Self>,
) -> Result<DecodeFinished, Error>where
I: Input,
fn decode_into<I>(
input: &mut I,
dst: &mut MaybeUninit<Self>,
) -> Result<DecodeFinished, Error>where
I: Input,
Source§impl Encode for ProtocolTimelines
impl Encode for ProtocolTimelines
Source§fn size_hint(&self) -> usize
fn size_hint(&self) -> usize
Source§fn encode_to<__CodecOutputEdqy: Output + ?Sized>(
&self,
__codec_dest_edqy: &mut __CodecOutputEdqy,
)
fn encode_to<__CodecOutputEdqy: Output + ?Sized>( &self, __codec_dest_edqy: &mut __CodecOutputEdqy, )
Source§fn using_encoded<R, F>(&self, f: F) -> R
fn using_encoded<R, F>(&self, f: F) -> R
Source§fn encoded_size(&self) -> usize
fn encoded_size(&self) -> usize
impl EncodeLike for ProtocolTimelines
impl Eq for ProtocolTimelines
Source§impl PartialEq for ProtocolTimelines
impl PartialEq for ProtocolTimelines
Source§fn eq(&self, other: &ProtocolTimelines) -> bool
fn eq(&self, other: &ProtocolTimelines) -> bool
self and other values to be equal, and is used by ==.impl StructuralPartialEq for ProtocolTimelines
Auto Trait Implementations§
impl Freeze for ProtocolTimelines
impl RefUnwindSafe for ProtocolTimelines
impl Send for ProtocolTimelines
impl Sync for ProtocolTimelines
impl Unpin for ProtocolTimelines
impl UnsafeUnpin for ProtocolTimelines
impl UnwindSafe for ProtocolTimelines
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<S> Codec for S
Source§impl<T> DecodeLimit for Twhere
T: Decode,
impl<T> DecodeLimit for Twhere
T: Decode,
impl<T> EncodeLike<&&T> for Twhere
T: Encode,
impl<T> EncodeLike<&T> for Twhere
T: Encode,
impl<T> EncodeLike<&mut T> for Twhere
T: Encode,
impl<T> EncodeLike<Arc<T>> for Twhere
T: Encode,
impl<T> EncodeLike<Box<T>> for Twhere
T: Encode,
impl<T> EncodeLike<Cow<'_, T>> for T
impl<T> EncodeLike<Rc<T>> for Twhere
T: Encode,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.impl<S> FullCodec for Swhere
S: Decode + FullEncode,
impl<S> FullEncode for Swhere
S: Encode + EncodeLike,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T, Outer> IsWrappedBy<Outer> for T
impl<T, Outer> IsWrappedBy<Outer> for T
impl<T> JsonSchemaMaybe for T
impl<T> MaybeDebug for Twhere
T: Debug,
impl<T> MaybeRefUnwindSafe for Twhere
T: RefUnwindSafe,
impl<T> StaticTypeInfo for Twhere
T: TypeInfo + 'static,
Source§impl<S, T> UncheckedInto<T> for Swhere
T: UncheckedFrom<S>,
impl<S, T> UncheckedInto<T> for Swhere
T: UncheckedFrom<S>,
Source§fn unchecked_into(self) -> T
fn unchecked_into(self) -> T
unchecked_from.