Commit d3c3a230 authored by Seungju Lee's avatar Seungju Lee

refactor: put GetAdminAPI as a separate function instead of directly coding it

parent 28aa528f
...@@ -5,7 +5,6 @@ import ( ...@@ -5,7 +5,6 @@ import (
"fmt" "fmt"
_ "net/http/pprof" _ "net/http/pprof"
gethrpc "github.com/ethereum/go-ethereum/rpc"
"github.com/urfave/cli/v2" "github.com/urfave/cli/v2"
"github.com/ethereum-optimism/optimism/op-batcher/flags" "github.com/ethereum-optimism/optimism/op-batcher/flags"
...@@ -82,10 +81,8 @@ func Main(version string, cliCtx *cli.Context) error { ...@@ -82,10 +81,8 @@ func Main(version string, cliCtx *cli.Context) error {
) )
if cfg.RPCFlag.EnableAdmin { if cfg.RPCFlag.EnableAdmin {
rpcMetrics := opmetrics.NewRPCMetrics(procName, metrics.Namespace) rpcMetrics := opmetrics.NewRPCMetrics(procName, metrics.Namespace)
server.AddAPI(gethrpc.API{ adminAPI := rpc.NewAdminAPI(batchSubmitter, rpcMetrics, l)
Namespace: "admin", server.AddAPI(rpc.GetAdminAPI(adminAPI))
Service: rpc.NewAdminAPI(batchSubmitter, rpcMetrics, l),
})
l.Info("Admin RPC enabled") l.Info("Admin RPC enabled")
} }
if err := server.Start(); err != nil { if err := server.Start(); err != nil {
......
...@@ -4,6 +4,7 @@ import ( ...@@ -4,6 +4,7 @@ import (
"context" "context"
"github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/log"
gethrpc "github.com/ethereum/go-ethereum/rpc"
"github.com/ethereum-optimism/optimism/op-service/metrics" "github.com/ethereum-optimism/optimism/op-service/metrics"
"github.com/ethereum-optimism/optimism/op-service/rpc" "github.com/ethereum-optimism/optimism/op-service/rpc"
...@@ -26,6 +27,13 @@ func NewAdminAPI(dr batcherClient, m metrics.RPCMetricer, log log.Logger) *admin ...@@ -26,6 +27,13 @@ func NewAdminAPI(dr batcherClient, m metrics.RPCMetricer, log log.Logger) *admin
} }
} }
func GetAdminAPI(api *adminAPI) gethrpc.API {
return gethrpc.API{
Namespace: "admin",
Service: api,
}
}
func (a *adminAPI) StartBatcher(_ context.Context) error { func (a *adminAPI) StartBatcher(_ context.Context) error {
return a.b.Start() return a.b.Start()
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment