From 768d4f6b00da30a5ae10f48489cd4075801a236b Mon Sep 17 00:00:00 2001 From: FelStroz Date: Tue, 10 May 2022 12:06:26 -0300 Subject: [PATCH 1/2] adding peer count function --- ethclient/ethclient.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/ethclient/ethclient.go b/ethclient/ethclient.go index 68389efbf437..233a51e19374 100644 --- a/ethclient/ethclient.go +++ b/ethclient/ethclient.go @@ -94,6 +94,13 @@ func (ec *Client) BlockNumber(ctx context.Context) (uint64, error) { return uint64(result), err } +// PeerCount returns the peer count +func (ec *Client) PeerCount(ctx context.Context) (uint64, error) { + var result hexutil.Uint64 + err := ec.c.CallContext(ctx, &result, "net_peerCount") + return uint64(result), err +} + type rpcBlock struct { Hash common.Hash `json:"hash"` Transactions []rpcTransaction `json:"transactions"` From b5d88bee7f46e277e50262ecd94d7d647b810f11 Mon Sep 17 00:00:00 2001 From: Felix Lange Date: Wed, 11 May 2022 00:24:14 +0200 Subject: [PATCH 2/2] Update ethclient.go --- ethclient/ethclient.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ethclient/ethclient.go b/ethclient/ethclient.go index 233a51e19374..24edd8648ef3 100644 --- a/ethclient/ethclient.go +++ b/ethclient/ethclient.go @@ -94,7 +94,7 @@ func (ec *Client) BlockNumber(ctx context.Context) (uint64, error) { return uint64(result), err } -// PeerCount returns the peer count +// PeerCount returns the number of p2p peers as reported by the net_peerCount method. func (ec *Client) PeerCount(ctx context.Context) (uint64, error) { var result hexutil.Uint64 err := ec.c.CallContext(ctx, &result, "net_peerCount")