Skip to content

Commit

Permalink
ethclient: add PeerCount method (ethereum#24849)
Browse files Browse the repository at this point in the history
* adding peer count function

* Update ethclient.go

Co-authored-by: Felix Lange <fjl@twurst.com>
  • Loading branch information
2 people authored and sadoci committed Jan 27, 2023
1 parent ec43348 commit eefb832
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions ethclient/ethclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,13 @@ func (ec *Client) BlockNumber(ctx context.Context) (uint64, error) {
return uint64(result), err
}

// 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")
return uint64(result), err
}

type rpcBlock struct {
Hash common.Hash `json:"hash"`
Transactions []rpcTransaction `json:"transactions"`
Expand Down

0 comments on commit eefb832

Please sign in to comment.