erigon-pulse/cmd/rpcdaemon/commands/daemon.go
Thomas Jay Rush c6c82b7569
Finish moving functions to consistent locations to ease testing/documentation of RPC (#1241)
* Cleaning up comments to start

* Renaming get_receipts.go to eth_receipts.go

* Stubbing out RPC mining routines

* Move block-related commands to eth_block.go

* Move transaction-related commands to eth_txs.go

* Move account-related commands to eth_accounts.go

* Move system-related commands to eth_system.go

* Final cleanup

* Updating testing
2020-10-14 16:59:42 +01:00

79 lines
2.0 KiB
Go

package commands
import (
"github.com/ledgerwatch/turbo-geth/cmd/rpcdaemon/cli"
"github.com/ledgerwatch/turbo-geth/ethdb"
"github.com/ledgerwatch/turbo-geth/rpc"
)
// APIList describes the list of available RPC apis
func APIList(db ethdb.KV, eth ethdb.Backend, cfg cli.Flags, customAPIList []rpc.API) []rpc.API {
var defaultAPIList []rpc.API
dbReader := ethdb.NewObjectDatabase(db)
ethImpl := NewEthAPI(db, dbReader, eth, cfg.Gascap)
netImpl := NewNetAPIImpl(eth)
debugImpl := NewPrivateDebugAPI(db, dbReader)
traceImpl := NewTraceAPI(db, dbReader, &cfg)
web3Impl := NewWeb3APIImpl()
dbImpl := NewDBAPIImpl() /* deprecated */
shhImpl := NewSHHAPIImpl() /* deprecated */
for _, enabledAPI := range cfg.API {
switch enabledAPI {
case "eth":
defaultAPIList = append(defaultAPIList, rpc.API{
Namespace: "eth",
Public: true,
Service: EthAPI(ethImpl),
Version: "1.0",
})
case "debug":
defaultAPIList = append(defaultAPIList, rpc.API{
Namespace: "debug",
Public: true,
Service: PrivateDebugAPI(debugImpl),
Version: "1.0",
})
case "net":
defaultAPIList = append(defaultAPIList, rpc.API{
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",
})
}
}
return append(defaultAPIList, customAPIList...)
}