Skip to content

Commit 61009b7

Browse files
fix: lint errors: ctx handling
1 parent 85baf97 commit 61009b7

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

rolling-shutter/keyperimpl/gnosis/metrics.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package gnosis
22

33
import (
4+
"context"
5+
46
"github.com/prometheus/client_golang/prometheus"
57
"github.com/rs/zerolog/log"
68

@@ -100,7 +102,7 @@ func init() {
100102
}
101103

102104
func InitMetrics(beaconClient *beaconapiclient.Client) {
103-
version, err := beaconClient.GetBeaconNodeVersion()
105+
version, err := beaconClient.GetBeaconNodeVersion(context.Background())
104106
if err != nil {
105107
log.Error().Err(err).Msg("Failed to get beacon node version")
106108
}

rolling-shutter/medley/beaconapiclient/beaconapiclient.go

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package beaconapiclient
22

33
import (
4+
"context"
45
"encoding/json"
56
"fmt"
67
"io"
@@ -24,12 +25,16 @@ func New(rawURL string) (*Client, error) {
2425
}, nil
2526
}
2627

27-
func (c *Client) GetBeaconNodeVersion() (string, error) {
28-
endpoint := "/eth/v1/node/version"
29-
resp, err := c.c.Get(c.url.JoinPath(endpoint).String())
28+
func (c *Client) GetBeaconNodeVersion(ctx context.Context) (string, error) {
29+
path := c.url.JoinPath("/eth/v1/node/version")
30+
req, err := http.NewRequestWithContext(ctx, "GET", path.String(), http.NoBody)
3031
if err != nil {
3132
return "", err
3233
}
34+
resp, err := http.DefaultClient.Do(req)
35+
if err != nil {
36+
return "", fmt.Errorf("failed to get beacon node version from consensus node: %w", err)
37+
}
3338
defer resp.Body.Close()
3439
if resp.StatusCode != http.StatusOK {
3540
return "", fmt.Errorf("unexpected status code: %d", resp.StatusCode)

0 commit comments

Comments
 (0)