2019-12-02 13:47:00 +00:00
|
|
|
package commands
|
|
|
|
|
|
|
|
import (
|
2021-03-30 07:09:00 +00:00
|
|
|
"context"
|
|
|
|
|
2020-08-19 11:46:20 +00:00
|
|
|
"github.com/ledgerwatch/turbo-geth/cmd/rpcdaemon/cli"
|
2020-11-17 19:13:41 +00:00
|
|
|
"github.com/ledgerwatch/turbo-geth/cmd/rpcdaemon/filters"
|
2021-03-23 09:00:07 +00:00
|
|
|
"github.com/ledgerwatch/turbo-geth/core"
|
2019-12-10 05:37:18 +00:00
|
|
|
"github.com/ledgerwatch/turbo-geth/ethdb"
|
2021-05-04 01:37:17 +00:00
|
|
|
"github.com/ledgerwatch/turbo-geth/gointerfaces/txpool"
|
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
|
2021-05-17 12:15:19 +00:00
|
|
|
func APIList(ctx context.Context, db ethdb.RoKV, eth core.ApiBackend, txPool txpool.TxpoolClient, mining txpool.MiningClient, filters *filters.Filters, 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
|
|
|
|
2021-05-17 12:15:19 +00:00
|
|
|
base := NewBaseApi(filters)
|
|
|
|
ethImpl := NewEthAPI(base, db, eth, txPool, mining, cfg.Gascap)
|
|
|
|
tgImpl := NewTgAPI(base, db)
|
2020-08-17 15:27:29 +00:00
|
|
|
netImpl := NewNetAPIImpl(eth)
|
2021-05-17 12:15:19 +00:00
|
|
|
debugImpl := NewPrivateDebugAPI(base, db, cfg.Gascap)
|
|
|
|
traceImpl := NewTraceAPI(base, db, &cfg)
|
2021-04-24 15:46:29 +00:00
|
|
|
web3Impl := NewWeb3APIImpl(eth)
|
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
|
|
|
}
|