Skip to content

Commit

Permalink
fix(metrics): calculate current fork on epoch change
Browse files Browse the repository at this point in the history
  • Loading branch information
samcm committed Jan 18, 2024
1 parent 4394f93 commit 634b504
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions pkg/beacon/metrics_fork.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,14 @@ func (f *ForkMetrics) Name() string {

// Start starts the job.
func (f *ForkMetrics) Start(ctx context.Context) error {
// TODO(sam.calder-mason): Update this to use the wall clock instead.
f.beacon.Wallclock().OnEpochChanged(func(epoch ethwallclock.Epoch) {
f.calculateCurrent(ctx)
f.beacon.OnReady(ctx, func(ctx context.Context, event *ReadyEvent) error {
f.beacon.Wallclock().OnEpochChanged(func(epoch ethwallclock.Epoch) {
if err := f.calculateCurrent(ctx); err != nil {
f.log.WithError(err).Error("Failed to calculate current fork")
}
})

return nil
})

return nil
Expand Down

0 comments on commit 634b504

Please sign in to comment.