mirror of
https://github.com/sigp/lighthouse.git
synced 2026-04-20 14:28:37 +00:00
Refactor slot clock.
This commit is contained in:
@@ -5,24 +5,19 @@ mod metrics;
|
||||
mod system_time_slot_clock;
|
||||
mod testing_slot_clock;
|
||||
|
||||
use std::time::Duration;
|
||||
use std::time::{Duration, Instant};
|
||||
|
||||
pub use crate::system_time_slot_clock::{Error as SystemTimeSlotClockError, SystemTimeSlotClock};
|
||||
pub use crate::testing_slot_clock::{Error as TestingSlotClockError, TestingSlotClock};
|
||||
pub use crate::system_time_slot_clock::SystemTimeSlotClock;
|
||||
pub use crate::testing_slot_clock::TestingSlotClock;
|
||||
pub use metrics::scrape_for_metrics;
|
||||
pub use types::Slot;
|
||||
|
||||
pub trait SlotClock: Send + Sync + Sized {
|
||||
type Error;
|
||||
fn new(genesis_slot: Slot, genesis: Instant, slot_duration: Duration) -> Self;
|
||||
|
||||
/// Create a new `SlotClock`.
|
||||
///
|
||||
/// Returns an Error if `slot_duration_seconds == 0`.
|
||||
fn new(genesis_slot: Slot, genesis_seconds: u64, slot_duration_seconds: u64) -> Self;
|
||||
fn present_slot(&self) -> Option<Slot>;
|
||||
|
||||
fn present_slot(&self) -> Result<Option<Slot>, Self::Error>;
|
||||
fn duration_to_next_slot(&self) -> Option<Duration>;
|
||||
|
||||
fn duration_to_next_slot(&self) -> Result<Option<Duration>, Self::Error>;
|
||||
|
||||
fn slot_duration_millis(&self) -> u64;
|
||||
fn slot_duration(&self) -> Duration;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user