ethclient: add PeerCount method #24849 (#1370)

This commit is contained in:
Daniel Liu 2025-08-22 16:43:26 +08:00 committed by GitHub
parent 1bf181eda6
commit aa88fe1d86
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -97,6 +97,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
}
// BlockReceipts returns the receipts of a given block number or hash
func (ec *Client) BlockReceipts(ctx context.Context, blockNrOrHash rpc.BlockNumberOrHash) ([]*types.Receipt, error) {
var r []*types.Receipt