Skip to content

Commit

Permalink
apply code review suggestions - revert to int
Browse files Browse the repository at this point in the history
  • Loading branch information
xenowits committed Jan 25, 2023
1 parent 9c4fea9 commit 55953e2
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 12 deletions.
14 changes: 3 additions & 11 deletions app/eth2wrap/httpwrap.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import (
"io"
"net/http"
"net/url"
"strconv"
"testing"
"time"

Expand All @@ -44,7 +43,7 @@ type BlockAttestationsProvider interface {

// PeerCount is the response for querying beacon node peer count (/eth/v1/node/peer_count).
type PeerCount struct {
Connected int64
Connected int
}

// NodePeerCountProvider is the interface for providing node peer count.
Expand Down Expand Up @@ -161,15 +160,8 @@ func (h *httpAdapter) NodePeerCount(ctx context.Context) (PeerCount, error) {
if err := json.Unmarshal(respBody, &resp); err != nil {
return PeerCount{}, errors.Wrap(err, "failed to parse beacon node peer count response")
}
if resp.Data.Connected == "" {
return PeerCount{}, errors.New("connected peers missing")
}
count, err := strconv.ParseInt(resp.Data.Connected, 10, 64)
if err != nil {
return PeerCount{}, errors.Wrap(err, "invalid value for connected peers")
}

return PeerCount{Connected: count}, nil
return PeerCount{Connected: resp.Data.Connected}, nil
}

type submitBeaconCommitteeSelectionsJSON struct {
Expand All @@ -186,7 +178,7 @@ type attestationsJSON struct {

type peerCountJSON struct {
Data struct {
Connected string `json:"connected"`
Connected int `json:"connected,string"`
} `json:"data"`
}

Expand Down
2 changes: 1 addition & 1 deletion app/monitoringapi.go
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ func peerCounter(ctx context.Context, eth2Cl eth2wrap.Client, clock clockwork.Cl
}

// beaconNodePeerCount returns the number of connected peers of the beacon node.
func beaconNodePeerCount(ctx context.Context, eth2Cl eth2wrap.Client) (int64, error) {
func beaconNodePeerCount(ctx context.Context, eth2Cl eth2wrap.Client) (int, error) {
peerCount, err := eth2Cl.NodePeerCount(ctx)
if err != nil {
return 0, errors.Wrap(err, "get beacon node peer count")
Expand Down

0 comments on commit 55953e2

Please sign in to comment.