mirror of
https://github.com/sigp/lighthouse.git
synced 2026-07-02 12:24:29 +00:00
Merge commit '1e029ce5384e911390a513e2d1885532f34a8b2b' into eip4844
This commit is contained in:
@@ -104,12 +104,23 @@ pub trait SlotClock: Send + Sync + Sized + Clone {
|
||||
self.slot_duration() * 2 / INTERVALS_PER_SLOT as u32
|
||||
}
|
||||
|
||||
/// Returns the `Duration` since the start of the current `Slot`. Useful in determining whether to apply proposer boosts.
|
||||
fn seconds_from_current_slot_start(&self, seconds_per_slot: u64) -> Option<Duration> {
|
||||
/// Returns the `Duration` since the start of the current `Slot` at seconds precision. Useful in determining whether to apply proposer boosts.
|
||||
fn seconds_from_current_slot_start(&self) -> Option<Duration> {
|
||||
self.now_duration()
|
||||
.and_then(|now| now.checked_sub(self.genesis_duration()))
|
||||
.map(|duration_into_slot| {
|
||||
Duration::from_secs(duration_into_slot.as_secs() % seconds_per_slot)
|
||||
Duration::from_secs(duration_into_slot.as_secs() % self.slot_duration().as_secs())
|
||||
})
|
||||
}
|
||||
|
||||
/// Returns the `Duration` since the start of the current `Slot` at milliseconds precision.
|
||||
fn millis_from_current_slot_start(&self) -> Option<Duration> {
|
||||
self.now_duration()
|
||||
.and_then(|now| now.checked_sub(self.genesis_duration()))
|
||||
.map(|duration_into_slot| {
|
||||
Duration::from_millis(
|
||||
(duration_into_slot.as_millis() % self.slot_duration().as_millis()) as u64,
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user