2019-12-02 13:47:00 +00:00
|
|
|
package commands
|
|
|
|
|
|
|
|
import (
|
2020-08-19 11:46:20 +00:00
|
|
|
"github.com/ledgerwatch/turbo-geth/cmd/rpcdaemon/cli"
|
2019-12-10 05:37:18 +00:00
|
|
|
"github.com/ledgerwatch/turbo-geth/ethdb"
|
2019-12-02 13:47:00 +00:00
|
|
|
"github.com/ledgerwatch/turbo-geth/rpc"
|
|
|
|
)
|
|
|
|
|
2020-10-12 08:39:33 +00:00
|
|
|
// APIList describes the list of available RPC apis
|
|
|
|
func APIList(db ethdb.KV, eth ethdb.Backend, cfg cli.Flags, customAPIList []rpc.API) []rpc.API {
|
2020-08-20 03:52:27 +00:00
|
|
|
var defaultAPIList []rpc.API
|
2020-04-04 07:18:10 +00:00
|
|
|
|
2020-07-22 01:31:47 +00:00
|
|
|
dbReader := ethdb.NewObjectDatabase(db)
|
2020-10-12 08:39:33 +00:00
|
|
|
|
|
|
|
ethImpl := NewEthAPI(db, dbReader, eth, cfg.Gascap)
|
2020-10-18 19:44:28 +00:00
|
|
|
tgImpl := NewTgAPI(db, dbReader)
|
2020-08-17 15:27:29 +00:00
|
|
|
netImpl := NewNetAPIImpl(eth)
|
2020-10-12 08:39:33 +00:00
|
|
|
debugImpl := NewPrivateDebugAPI(db, dbReader)
|
|
|
|
traceImpl := NewTraceAPI(db, dbReader, &cfg)
|
2020-09-11 13:12:38 +00:00
|
|
|
web3Impl := NewWeb3APIImpl()
|
2020-10-12 08:39:33 +00:00
|
|
|
dbImpl := NewDBAPIImpl() /* deprecated */
|
|
|
|
shhImpl := NewSHHAPIImpl() /* deprecated */
|
2019-12-16 14:54:30 +00:00
|
|
|
|
2020-08-19 11:46:20 +00:00
|
|
|
for _, enabledAPI := range cfg.API {
|
2019-12-02 13:47:00 +00:00
|
|
|
switch enabledAPI {
|
|
|
|
case "eth":
|
2020-08-20 03:52:27 +00:00
|
|
|
defaultAPIList = append(defaultAPIList, rpc.API{
|
2019-12-02 13:47:00 +00:00
|
|
|
Namespace: "eth",
|
|
|
|
Public: true,
|
2020-10-12 08:39:33 +00:00
|
|
|
Service: EthAPI(ethImpl),
|
2019-12-02 13:47:00 +00:00
|
|
|
Version: "1.0",
|
|
|
|
})
|
2019-12-10 05:37:18 +00:00
|
|
|
case "debug":
|
2020-08-20 03:52:27 +00:00
|
|
|
defaultAPIList = append(defaultAPIList, rpc.API{
|
2019-12-10 05:37:18 +00:00
|
|
|
Namespace: "debug",
|
|
|
|
Public: true,
|
2020-10-12 08:39:33 +00:00
|
|
|
Service: PrivateDebugAPI(debugImpl),
|
2019-12-10 05:37:18 +00:00
|
|
|
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",
|
|
|
|
})
|
2020-09-11 13:12:38 +00:00
|
|
|
case "web3":
|
|
|
|
defaultAPIList = append(defaultAPIList, rpc.API{
|
|
|
|
Namespace: "web3",
|
|
|
|
Public: true,
|
|
|
|
Service: Web3API(web3Impl),
|
|
|
|
Version: "1.0",
|
|
|
|
})
|
2020-08-29 15:50:24 +00:00
|
|
|
case "trace":
|
|
|
|
defaultAPIList = append(defaultAPIList, rpc.API{
|
|
|
|
Namespace: "trace",
|
|
|
|
Public: true,
|
2020-10-12 08:39:33 +00:00
|
|
|
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),
|
2020-08-29 15:50:24 +00:00
|
|
|
Version: "1.0",
|
|
|
|
})
|
2020-10-18 19:44:28 +00:00
|
|
|
case "tg":
|
|
|
|
defaultAPIList = append(defaultAPIList, rpc.API{
|
|
|
|
Namespace: "tg",
|
|
|
|
Public: true,
|
|
|
|
Service: TgAPI(tgImpl),
|
|
|
|
Version: "1.0",
|
|
|
|
})
|
2019-12-02 13:47:00 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-10-12 08:39:33 +00:00
|
|
|
return append(defaultAPIList, customAPIList...)
|
2019-12-02 13:47:00 +00:00
|
|
|
}
|