-
Notifications
You must be signed in to change notification settings - Fork 3.3k
/
api.go
43 lines (34 loc) · 902 Bytes
/
api.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package rpc
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"
)
type ProposerDriver interface {
StartL2OutputSubmitting() error
StopL2OutputSubmitting() error
}
type adminAPI struct {
*rpc.CommonAdminAPI
b ProposerDriver
}
func NewAdminAPI(dr ProposerDriver, m metrics.RPCMetricer, log log.Logger) *adminAPI {
return &adminAPI{
CommonAdminAPI: rpc.NewCommonAdminAPI(m, log),
b: dr,
}
}
func GetAdminAPI(api *adminAPI) gethrpc.API {
return gethrpc.API{
Namespace: "admin",
Service: api,
}
}
func (a *adminAPI) StartProposer(_ context.Context) error {
return a.b.StartL2OutputSubmitting()
}
func (a *adminAPI) StopProposer(ctx context.Context) error {
return a.b.StopL2OutputSubmitting()
}