mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-20 13:24:44 +00:00
Enr fork (#967)
* Start fixing enr-fork-id * Fix time-until-next-fork logic * Remove fork crate
This commit is contained in:
@@ -35,6 +35,9 @@ pub trait SlotClock: Send + Sync + Sized {
|
||||
/// Returns the duration between slots
|
||||
fn slot_duration(&self) -> Duration;
|
||||
|
||||
/// Returns the duration from now until `slot`.
|
||||
fn duration_to_slot(&self, slot: Slot) -> Option<Duration>;
|
||||
|
||||
/// Returns the duration until the next slot.
|
||||
fn duration_to_next_slot(&self) -> Option<Duration>;
|
||||
|
||||
|
||||
@@ -135,6 +135,10 @@ impl SlotClock for ManualSlotClock {
|
||||
self.slot_duration
|
||||
}
|
||||
|
||||
fn duration_to_slot(&self, slot: Slot) -> Option<Duration> {
|
||||
self.duration_to_slot(slot, *self.current_time.read())
|
||||
}
|
||||
|
||||
fn genesis_slot(&self) -> Slot {
|
||||
self.genesis_slot
|
||||
}
|
||||
|
||||
@@ -44,6 +44,11 @@ impl SlotClock for SystemTimeSlotClock {
|
||||
self.clock.slot_duration()
|
||||
}
|
||||
|
||||
fn duration_to_slot(&self, slot: Slot) -> Option<Duration> {
|
||||
let now = SystemTime::now().duration_since(UNIX_EPOCH).ok()?;
|
||||
self.clock.duration_to_slot(slot, now)
|
||||
}
|
||||
|
||||
fn genesis_slot(&self) -> Slot {
|
||||
self.clock.genesis_slot()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user