Skip to content

Commit

Permalink
Move metrics
Browse files Browse the repository at this point in the history
  • Loading branch information
samcm committed Sep 22, 2023
1 parent 7fe62df commit 7c380cd
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions pkg/cannon/ethereum/beacon.go
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,8 @@ func (b *BeaconNode) Synced(ctx context.Context) error {

// GetBeaconBlock returns a beacon block by its identifier. Blocks can be cached internally.
func (b *BeaconNode) GetBeaconBlock(ctx context.Context, identifier string, ignoreMetrics ...bool) (*spec.VersionedSignedBeaconBlock, error) {
b.metrics.IncBlocksFetched(string(b.Metadata().Network.Name))

// Use singleflight to ensure we only make one request for a block at a time.
x, err, _ := b.sfGroup.Do(identifier, func() (interface{}, error) {
// Check the cache first.
Expand Down Expand Up @@ -237,10 +239,6 @@ func (b *BeaconNode) GetBeaconBlock(ctx context.Context, identifier string, igno
return nil, err
}

if len(ignoreMetrics) != 0 && ignoreMetrics[0] {
b.metrics.IncBlocksFetched(string(b.Metadata().Network.Name))
}

return x.(*spec.VersionedSignedBeaconBlock), nil
}

Expand Down

0 comments on commit 7c380cd

Please sign in to comment.