erigon-pulse/cmd/rpcdaemon/commands/daemon.go

91 lines
2.4 KiB
Go
Raw Normal View History

package commands
import (
"context"
"github.com/ledgerwatch/turbo-geth/cmd/rpcdaemon/cli"
"github.com/ledgerwatch/turbo-geth/cmd/rpcdaemon/filters"
2021-03-23 09:00:07 +00:00
"github.com/ledgerwatch/turbo-geth/core"
"github.com/ledgerwatch/turbo-geth/ethdb"
"github.com/ledgerwatch/turbo-geth/rpc"
"github.com/ledgerwatch/turbo-geth/turbo/rpchelper"
)
// APIList describes the list of available RPC apis
2021-03-30 09:53:54 +00:00
func APIList(ctx context.Context, kv ethdb.RoKV, eth core.ApiBackend, filters *filters.Filters, cfg cli.Flags, customAPIList []rpc.API) []rpc.API {
2020-08-20 03:52:27 +00:00
var defaultAPIList []rpc.API
pending := rpchelper.NewPending(filters, ctx.Done())
2021-03-30 09:53:54 +00:00
ethImpl := NewEthAPI(kv, eth, cfg.Gascap, filters, pending)
tgImpl := NewTgAPI(kv, pending)
2020-08-17 15:27:29 +00:00
netImpl := NewNetAPIImpl(eth)
2021-03-30 09:53:54 +00:00
debugImpl := NewPrivateDebugAPI(kv, cfg.Gascap, pending)
traceImpl := NewTraceAPI(kv, pending, &cfg)
web3Impl := NewWeb3APIImpl()
dbImpl := NewDBAPIImpl() /* deprecated */
shhImpl := NewSHHAPIImpl() /* deprecated */
2019-12-16 14:54:30 +00:00
for _, enabledAPI := range cfg.API {
switch enabledAPI {
case "eth":
2020-08-20 03:52:27 +00:00
defaultAPIList = append(defaultAPIList, rpc.API{
Namespace: "eth",
Public: true,
Service: EthAPI(ethImpl),
Version: "1.0",
})
case "debug":
2020-08-20 03:52:27 +00:00
defaultAPIList = append(defaultAPIList, rpc.API{
Namespace: "debug",
Public: true,
Service: PrivateDebugAPI(debugImpl),
Version: "1.0",
})
2020-08-17 15:27:29 +00:00
case "net":
2020-08-20 03:52:27 +00:00
defaultAPIList = append(defaultAPIList, rpc.API{
2020-08-17 15:27:29 +00:00
Namespace: "net",
Public: true,
Service: NetAPI(netImpl),
Version: "1.0",
})
case "web3":
defaultAPIList = append(defaultAPIList, rpc.API{
Namespace: "web3",
Public: true,
Service: Web3API(web3Impl),
Version: "1.0",
})
case "trace":
defaultAPIList = append(defaultAPIList, rpc.API{
Namespace: "trace",
Public: true,
Service: TraceAPI(traceImpl),
Version: "1.0",
})
case "db":
defaultAPIList = append(defaultAPIList, rpc.API{
Namespace: "db",
Public: true,
Service: DBAPI(dbImpl),
Version: "1.0",
})
case "shh":
defaultAPIList = append(defaultAPIList, rpc.API{
Namespace: "shh",
Public: true,
Service: SHHAPI(shhImpl),
Version: "1.0",
})
case "tg":
defaultAPIList = append(defaultAPIList, rpc.API{
Namespace: "tg",
Public: true,
Service: TgAPI(tgImpl),
Version: "1.0",
})
}
}
return append(defaultAPIList, customAPIList...)
}