diff --git a/cmd/rpcdaemon/commands/daemon.go b/cmd/rpcdaemon/commands/daemon.go index e2f4f9fcd..d57904ff2 100644 --- a/cmd/rpcdaemon/commands/daemon.go +++ b/cmd/rpcdaemon/commands/daemon.go @@ -139,6 +139,7 @@ func GetAPI(db ethdb.KV, eth ethdb.Backend, enabledApis []string) []rpc.API { dbReader := ethdb.NewObjectDatabase(db) chainContext := NewChainContext(dbReader) apiImpl := NewAPI(db, dbReader, chainContext, eth) + netImpl := NewNetAPIImpl(eth) dbgAPIImpl := NewPrivateDebugAPI(db, dbReader, chainContext) for _, enabledAPI := range enabledApis { @@ -157,6 +158,13 @@ func GetAPI(db ethdb.KV, eth ethdb.Backend, enabledApis []string) []rpc.API { Service: PrivateDebugAPI(dbgAPIImpl), Version: "1.0", }) + case "net": + rpcAPI = append(rpcAPI, rpc.API{ + Namespace: "net", + Public: true, + Service: NetAPI(netImpl), + Version: "1.0", + }) default: log.Error("Unrecognised", "api", enabledAPI) diff --git a/cmd/rpcdaemon/commands/eth_api.go b/cmd/rpcdaemon/commands/eth_api.go index 98703f034..4112ec47b 100644 --- a/cmd/rpcdaemon/commands/eth_api.go +++ b/cmd/rpcdaemon/commands/eth_api.go @@ -17,7 +17,6 @@ import ( // EthAPI is a collection of functions that are exposed in the type EthAPI interface { Coinbase(ctx context.Context) (common.Address, error) - NetVersion(ctx context.Context) uint64 BlockNumber(ctx context.Context) (hexutil.Uint64, error) GetBlockByNumber(ctx context.Context, number rpc.BlockNumber, fullTx bool) (map[string]interface{}, error) GetBalance(ctx context.Context, address common.Address, blockNrOrHash rpc.BlockNumberOrHash) (*hexutil.Big, error) diff --git a/cmd/rpcdaemon/commands/net.go b/cmd/rpcdaemon/commands/net.go new file mode 100644 index 000000000..ae3a1fe14 --- /dev/null +++ b/cmd/rpcdaemon/commands/net.go @@ -0,0 +1,22 @@ +package commands + +import ( + "context" + + "github.com/ledgerwatch/turbo-geth/ethdb" +) + +type NetAPI interface { + Version(ctx context.Context) uint64 +} + +type NetAPIImpl struct { + ethBackend ethdb.Backend +} + +// NwtNetAPIImpl returns NetAPIImplImpl instance +func NewNetAPIImpl(eth ethdb.Backend) *NetAPIImpl { + return &NetAPIImpl{ + ethBackend: eth, + } +} diff --git a/cmd/rpcdaemon/commands/net_version.go b/cmd/rpcdaemon/commands/net_version.go index cc2edc0b3..bb92498e5 100644 --- a/cmd/rpcdaemon/commands/net_version.go +++ b/cmd/rpcdaemon/commands/net_version.go @@ -4,6 +4,6 @@ import ( "context" ) -func (api *APIImpl) NetVersion(_ context.Context) uint64 { +func (api *NetAPIImpl) Version(_ context.Context) uint64 { return api.ethBackend.NetVersion() }