Skip to content

Commit f5ff022

Browse files
FelStrozfjl
andauthored
ethclient: add PeerCount method (#24849)
* adding peer count function * Update ethclient.go Co-authored-by: Felix Lange <[email protected]>
1 parent 539bbd6 commit f5ff022

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

ethclient/ethclient.go

+7
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,13 @@ func (ec *Client) BlockNumber(ctx context.Context) (uint64, error) {
9494
return uint64(result), err
9595
}
9696

97+
// PeerCount returns the number of p2p peers as reported by the net_peerCount method.
98+
func (ec *Client) PeerCount(ctx context.Context) (uint64, error) {
99+
var result hexutil.Uint64
100+
err := ec.c.CallContext(ctx, &result, "net_peerCount")
101+
return uint64(result), err
102+
}
103+
97104
type rpcBlock struct {
98105
Hash common.Hash `json:"hash"`
99106
Transactions []rpcTransaction `json:"transactions"`

0 commit comments

Comments
 (0)