mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-02-26 15:47:21 +00:00
ethclient: add PeerCount method (#24849)
* adding peer count function * Update ethclient.go Co-authored-by: Felix Lange <fjl@twurst.com>
This commit is contained in:
parent
539bbd6349
commit
f5ff022dbc
1 changed files with 7 additions and 0 deletions
|
|
@ -94,6 +94,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"`
|
||||
|
|
|
|||
Loading…
Reference in a new issue