pub struct Epoch {
pub id: EpochId,
pub state: EpochState,
pub started_at: Time,
pub expected_end: Time,
pub ended_at: Option<Time>,
pub config: EpochConfig,
pub operation_count: u64,
pub metadata: DetHashMap<String, String>,
}Expand description
Full epoch state with metadata.
Fields§
§id: EpochIdUnique identifier.
state: EpochStateCurrent state.
started_at: TimeWhen this epoch started.
expected_end: TimeWhen this epoch is expected to end.
ended_at: Option<Time>When this epoch actually ended (if ended).
config: EpochConfigConfiguration for this epoch.
operation_count: u64Number of operations executed in this epoch.
metadata: DetHashMap<String, String>Custom metadata.
Implementations§
Source§impl Epoch
impl Epoch
Sourcepub fn new(id: EpochId, started_at: Time, config: EpochConfig) -> Self
pub fn new(id: EpochId, started_at: Time, config: EpochConfig) -> Self
Creates a new epoch.
Sourcepub fn genesis(config: EpochConfig) -> Self
pub fn genesis(config: EpochConfig) -> Self
Creates the genesis epoch.
Sourcepub fn duration(&self, now: Time) -> Duration
pub fn duration(&self, now: Time) -> Duration
Returns the duration of this epoch (or elapsed time if still active).
Sourcepub fn is_overdue(&self, now: Time) -> bool
pub fn is_overdue(&self, now: Time) -> bool
Returns true if the epoch has exceeded its maximum duration.
Sourcepub fn can_transition(&self, now: Time) -> bool
pub fn can_transition(&self, now: Time) -> bool
Returns true if the epoch can transition (met minimum duration).
Sourcepub fn remaining(&self, now: Time) -> Option<Duration>
pub fn remaining(&self, now: Time) -> Option<Duration>
Returns the time remaining until expected end.
Sourcepub fn record_operation(&mut self)
pub fn record_operation(&mut self)
Records an operation.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Epoch
impl RefUnwindSafe for Epoch
impl Send for Epoch
impl Sync for Epoch
impl Unpin for Epoch
impl UnsafeUnpin for Epoch
impl UnwindSafe for Epoch
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, _span: NoopSpan) -> Self
fn instrument(self, _span: NoopSpan) -> Self
Instruments this future with a span (no-op when disabled).
Source§fn in_current_span(self) -> Self
fn in_current_span(self) -> Self
Instruments this future with the current span (no-op when disabled).