Skip to content

Commit

Permalink
Merge ecdde04 into 1397834
Browse files Browse the repository at this point in the history
  • Loading branch information
nflaig authored Sep 29, 2023
2 parents 1397834 + ecdde04 commit 5b286ce
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion packages/beacon-node/src/node/notifier.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,12 @@ function timeToNextHalfSlot(config: BeaconConfig, chain: IBeaconChain, isFirstTi
const msPerSlot = config.SECONDS_PER_SLOT * 1000;
const msPerHalfSlot = msPerSlot / 2;
const msFromGenesis = Date.now() - chain.genesisTime * 1000;
const msToNextSlot = msPerSlot - (msFromGenesis % msPerSlot);
const msToNextSlot =
msFromGenesis < 0
? // For future genesis time, calculate time left in the slot
-msFromGenesis % msPerSlot
: // For past genesis time, calculate time until the next slot
msPerSlot - (msFromGenesis % msPerSlot);
if (isFirstTime) {
// at the 1st time we may miss middle of the current clock slot
return msToNextSlot > msPerHalfSlot ? msToNextSlot - msPerHalfSlot : msToNextSlot + msPerHalfSlot;
Expand Down

0 comments on commit 5b286ce

Please sign in to comment.