Skip to content

Commit

Permalink
refactor: Simplify proposer duty event creation
Browse files Browse the repository at this point in the history
  • Loading branch information
samcm committed Apr 2, 2024
1 parent 2095be4 commit 05772e0
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions pkg/sentry/proposer_duty.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down

0 comments on commit 05772e0

Please sign in to comment.