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 (
"fmt"
_ "net/http/pprof"
gethrpc "github.com/ethereum/go-ethereum/rpc"
"github.com/urfave/cli/v2"
"github.com/ethereum-optimism/optimism/op-batcher/flags"
......@@ -82,10 +81,8 @@ func Main(version string, cliCtx *cli.Context) error {
)
if cfg.RPCFlag.EnableAdmin {
rpcMetrics := opmetrics.NewRPCMetrics(procName, metrics.Namespace)
server.AddAPI(gethrpc.API{
Namespace: "admin",
Service: rpc.NewAdminAPI(batchSubmitter, rpcMetrics, l),
})
adminAPI := rpc.NewAdminAPI(batchSubmitter, rpcMetrics, l)
server.AddAPI(rpc.GetAdminAPI(adminAPI))
l.Info("Admin RPC enabled")
}
if err := server.Start(); err != nil {
......
......@@ -4,6 +4,7 @@ import (
"context"
"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/rpc"
......@@ -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 {
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