github.com/lmittmann/w3@v0.20.0/module/net/net.go (about) 1 /* 2 Package net implements RPC API bindings for methods in the "net" namespace. 3 */ 4 package net 5 6 import ( 7 "github.com/lmittmann/w3/internal/module" 8 "github.com/lmittmann/w3/w3types" 9 ) 10 11 // Listening returns whether the client is actively listening for network connections. 12 func Listening() w3types.RPCCallerFactory[bool] { 13 return module.NewFactory[bool]( 14 "net_listening", 15 []any{}, 16 ) 17 } 18 19 // PeerCount returns the number of peers connected to the node. 20 func PeerCount() w3types.RPCCallerFactory[int] { 21 return module.NewFactory[int]( 22 "net_peerCount", 23 []any{}, 24 ) 25 } 26 27 // Version returns the network ID (e.g. 1 for mainnet). 28 func Version() w3types.RPCCallerFactory[int] { 29 return module.NewFactory[int]( 30 "net_version", 31 []any{}, 32 ) 33 }