Skip to content

Commit

Permalink
refactor: Remove unnecessary slot variable and optimize epoch handling
Browse files Browse the repository at this point in the history
  • Loading branch information
samcm committed Jan 20, 2025
1 parent cf2bfb2 commit 7c62b89
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions pkg/cannon/cannon.go
Original file line number Diff line number Diff line change
Expand Up @@ -700,8 +700,6 @@ func (c *Cannon) startDeriverWhenReady(ctx context.Context, d deriver.EventDeriv
continue
}

slot := c.beacon.Node().Wallclock().Slots().Current()

fork, err := spec.ForkEpochs.GetByName(d.ActivationFork())
if err != nil {
c.log.WithError(err).Errorf("unknown activation fork: %s", d.ActivationFork())
Expand All @@ -713,10 +711,10 @@ func (c *Cannon) startDeriverWhenReady(ctx context.Context, d deriver.EventDeriv
continue
}

if !fork.Active(phase0.Slot(slot.Number()), spec.SlotsPerEpoch) {
// Sleep until the next epochl and then retrty
currentEpoch := c.beacon.Metadata().Wallclock().Epochs().Current()
// Sleep until the next epochl and then retrty
currentEpoch := c.beacon.Metadata().Wallclock().Epochs().Current()

if !fork.Active(phase0.Epoch(currentEpoch.Number())) {
activationForkEpoch := c.beacon.Node().Wallclock().Epochs().FromNumber(uint64(fork.Epoch))

sleepFor := time.Until(activationForkEpoch.TimeWindow().End())
Expand Down

0 comments on commit 7c62b89

Please sign in to comment.