erigon-pulse/cmd/rpcdaemon/commands/net_api.go
Thomas Jay Rush f596a631af
1075 RPC additions and cleanup of README (#1117)
* Rewrite of README for clarity and expanding implementation table

* Small cleanups for web3_api.go

* Changed GetReceipts function to non-export (getRecipts) and cleaned up comments

* Added a comment for GetLogsByHash

* Add support for eth_protocolVersion and eth_chainId

* Adding comments and re-ordering fields to agree with Parity's ordering

* Added support for eth_listening. Moved net_version to same file as others

* Setup for adding eth_gasPrice
2020-09-15 17:44:28 +01:00

49 lines
1.1 KiB
Go

package commands
import (
"context"
"strconv"
"github.com/ledgerwatch/turbo-geth/common/hexutil"
"github.com/ledgerwatch/turbo-geth/ethdb"
)
type NetAPI interface {
Listening(_ context.Context) (bool, error)
Version(_ context.Context) (string, error)
PeerCount(_ context.Context) (hexutil.Uint, error)
}
type NetAPIImpl struct {
ethBackend ethdb.Backend
}
// NewtNetAPIImpl returns NetAPIImplImpl instance
func NewNetAPIImpl(eth ethdb.Backend) *NetAPIImpl {
return &NetAPIImpl{
ethBackend: eth,
}
}
// Listen implements RPC call for net_listening
// TODO(tjayrush) remove hard coded value
func (api *NetAPIImpl) Listening(_ context.Context) (bool, error) {
return true, nil
}
// Version implements RPC call for net_version
func (api *NetAPIImpl) Version(_ context.Context) (string, error) {
res, err := api.ethBackend.NetVersion()
if err != nil {
return "", err
}
return strconv.FormatUint(res, 10), nil
}
// PeerCount implements RPC call for net_peerCount
// TODO(tjayrush) remove hard coded value
func (api *NetAPIImpl) PeerCount(_ context.Context) (hexutil.Uint, error) {
return hexutil.Uint(25), nil
}