2019-12-02 13:47:00 +00:00
|
|
|
package commands
|
|
|
|
|
|
|
|
import (
|
2021-03-30 07:09:00 +00:00
|
|
|
"context"
|
|
|
|
|
2021-07-01 21:31:14 +00:00
|
|
|
"github.com/ledgerwatch/erigon-lib/gointerfaces/txpool"
|
2021-07-29 11:53:13 +00:00
|
|
|
"github.com/ledgerwatch/erigon-lib/kv"
|
2021-05-20 18:25:53 +00:00
|
|
|
"github.com/ledgerwatch/erigon/cmd/rpcdaemon/cli"
|
|
|
|
"github.com/ledgerwatch/erigon/cmd/rpcdaemon/filters"
|
2021-05-22 10:00:13 +00:00
|
|
|
"github.com/ledgerwatch/erigon/cmd/rpcdaemon/services"
|
2021-05-20 18:25:53 +00:00
|
|
|
"github.com/ledgerwatch/erigon/rpc"
|
2019-12-02 13:47:00 +00:00
|
|
|
)
|
|
|
|
|
2020-10-12 08:39:33 +00:00
|
|
|
// APIList describes the list of available RPC apis
|
2021-07-28 02:47:38 +00:00
|
|
|
func APIList(ctx context.Context, db kv.RoDB, eth services.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)
|
2021-05-26 10:35:39 +00:00
|
|
|
erigonImpl := NewErigonAPI(base, db)
|
2021-06-11 08:34:47 +00:00
|
|
|
txpoolImpl := NewTxPoolAPI(base, db, txPool)
|
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",
|
|
|
|
})
|
2021-06-11 08:34:47 +00:00
|
|
|
case "txpool":
|
|
|
|
defaultAPIList = append(defaultAPIList, rpc.API{
|
|
|
|
Namespace: "txpool",
|
|
|
|
Public: true,
|
|
|
|
Service: TxPoolAPI(txpoolImpl),
|
|
|
|
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",
|
|
|
|
})
|
2021-05-26 10:35:39 +00:00
|
|
|
case "erigon":
|
2020-10-18 19:44:28 +00:00
|
|
|
defaultAPIList = append(defaultAPIList, rpc.API{
|
2021-05-26 10:35:39 +00:00
|
|
|
Namespace: "erigon",
|
2020-10-18 19:44:28 +00:00
|
|
|
Public: true,
|
2021-05-26 10:35:39 +00:00
|
|
|
Service: ErigonAPI(erigonImpl),
|
2020-10-18 19:44:28 +00:00
|
|
|
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
|
|
|
}
|