From 05772e04636fce8ae0dd7d754aca47d4add6f00e Mon Sep 17 00:00:00 2001 From: Sam Calder-Mason Date: Tue, 2 Apr 2024 16:51:07 +1000 Subject: [PATCH] refactor: Simplify proposer duty event creation --- pkg/sentry/proposer_duty.go | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/pkg/sentry/proposer_duty.go b/pkg/sentry/proposer_duty.go index bd40de85..17dc8880 100644 --- a/pkg/sentry/proposer_duty.go +++ b/pkg/sentry/proposer_duty.go @@ -10,20 +10,19 @@ import ( ) func (s *Sentry) startProposerDutyWatcher(ctx context.Context) error { - if !s.Config.BeaconCommittees.Enabled { + if !s.Config.ProposerDuty.Enabled { return nil } + // Subscribe to future proposer duty events. + s.beacon.Duties().OnProposerDuties(func(epoch phase0.Epoch, duties []*eth2v1.ProposerDuty) error { + if err := s.createNewProposerDutyEvent(ctx, epoch, duties); err != nil { + s.log.WithError(err).Error("Failed to create new proposer duties event") + } - s.beacon.OnReady(ctx, func(ctx context.Context) error { - // Subscribe to future proposer duty events. - s.beacon.Duties().OnProposerDuties(func(epoch phase0.Epoch, duties []*eth2v1.ProposerDuty) error { - if err := s.createNewProposerDutyEvent(ctx, epoch, duties); err != nil { - s.log.WithError(err).Error("Failed to create new proposer duties event") - } - - return nil - }) + return nil + }) + s.beacon.OnReady(ctx, func(ctx context.Context) error { // Grab the current epoch duties. now := s.beacon.Metadata().Wallclock().Epochs().Current() epochs := []phase0.Epoch{