Skip to content

Commit aa88fe1

Browse files
authored
ethclient: add PeerCount method ethereum#24849 (#1370)
1 parent 1bf181e commit aa88fe1

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

ethclient/ethclient.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,13 @@ func (ec *Client) BlockNumber(ctx context.Context) (uint64, error) {
9797
return uint64(result), err
9898
}
9999

100+
// PeerCount returns the number of p2p peers as reported by the net_peerCount method.
101+
func (ec *Client) PeerCount(ctx context.Context) (uint64, error) {
102+
var result hexutil.Uint64
103+
err := ec.c.CallContext(ctx, &result, "net_peerCount")
104+
return uint64(result), err
105+
}
106+
100107
// BlockReceipts returns the receipts of a given block number or hash
101108
func (ec *Client) BlockReceipts(ctx context.Context, blockNrOrHash rpc.BlockNumberOrHash) ([]*types.Receipt, error) {
102109
var r []*types.Receipt

0 commit comments

Comments
 (0)