mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-02 16:21:42 +00:00
Represent slots in secs instead of millisecs (#2163)
## Issue Addressed NA ## Proposed Changes Copied from #2083, changes the config milliseconds_per_slot to seconds_per_slot to avoid errors when slot duration is not a multiple of a second. To avoid deserializing old serialized data (with milliseconds instead of seconds) the Serialize and Deserialize derive got removed from the Spec struct (isn't currently used anyway). This PR replaces #2083 for the purpose of fixing a merge conflict without requiring the input of @blacktemplar. ## Additional Info NA Co-authored-by: blacktemplar <blacktemplar@a1.net>
This commit is contained in:
@@ -14,7 +14,7 @@ use tokio::time::{interval_at, Instant};
|
||||
pub fn spawn_timer<T: BeaconChainTypes>(
|
||||
executor: task_executor::TaskExecutor,
|
||||
beacon_chain: Arc<BeaconChain<T>>,
|
||||
milliseconds_per_slot: u64,
|
||||
seconds_per_slot: u64,
|
||||
) -> Result<(), &'static str> {
|
||||
let log = executor.log();
|
||||
let start_instant = Instant::now()
|
||||
@@ -23,8 +23,8 @@ pub fn spawn_timer<T: BeaconChainTypes>(
|
||||
.duration_to_next_slot()
|
||||
.ok_or("slot_notifier unable to determine time to next slot")?;
|
||||
|
||||
// Warning: `interval_at` panics if `milliseconds_per_slot` = 0.
|
||||
let mut interval = interval_at(start_instant, Duration::from_millis(milliseconds_per_slot));
|
||||
// Warning: `interval_at` panics if `seconds_per_slot` = 0.
|
||||
let mut interval = interval_at(start_instant, Duration::from_secs(seconds_per_slot));
|
||||
let timer_future = async move {
|
||||
while interval.next().await.is_some() {
|
||||
beacon_chain.per_slot_task();
|
||||
|
||||
Reference in New Issue
Block a user