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

99 lines
2.7 KiB
Go
Raw Normal View History

package commands
import (
"context"
"github.com/ledgerwatch/erigon-lib/gointerfaces/txpool"
2021-07-29 11:53:13 +00:00
"github.com/ledgerwatch/erigon-lib/kv"
"github.com/ledgerwatch/erigon/cmd/rpcdaemon/cli"
"github.com/ledgerwatch/erigon/cmd/rpcdaemon/filters"
"github.com/ledgerwatch/erigon/cmd/rpcdaemon/services"
"github.com/ledgerwatch/erigon/rpc"
)
// APIList describes the list of available RPC apis
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
base := NewBaseApi(filters)
ethImpl := NewEthAPI(base, db, eth, txPool, mining, cfg.Gascap)
erigonImpl := NewErigonAPI(base, db)
txpoolImpl := NewTxPoolAPI(base, db, txPool)
2020-08-17 15:27:29 +00:00
netImpl := NewNetAPIImpl(eth)
debugImpl := NewPrivateDebugAPI(base, db, cfg.Gascap)
traceImpl := NewTraceAPI(base, db, &cfg)
Integration tests 1 (#1793) * Initial commit * Add sentry gRPC interface * p2psentry directory * Update README.md * Update README.md * Update README.md * Add go package * Correct syntax * add external downloader interface (#2) * Add txpool (#3) * Add private API (#4) * Invert control.proto, add PeerMinBlock, Separare incoming Tx message into a separate stream (#5) Co-authored-by: Alexey Sharp <alexeysharp@Alexeys-iMac.local> * Separate upload messages into its own stream (#6) Co-authored-by: Alexey Sharp <alexeysharp@Alexeys-iMac.local> * Only send changed accounts to listeners (#7) * Txpool interface doc (#9) * Add architecture diagram source and picture (#10) * Typed hashes (#11) * Typed hashes * Fix PeerId * 64-bit tx nonce * Add proper golang packages, max_block into p2p sentry Status (#12) * Add proper golang packages, max_block into p2p sentry Status * Change EtherReply to address Co-authored-by: Alexey Sharp <alexeysharp@Alexeys-iMac.local> * Add Rust infrastructure (#13) * DB stats methods removed by https://github.com/ledgerwatch/turbo-geth/pull/1665 * more p2p methods (#15) * add mining methods (#16) * First draft of Consensus gRPC interface (#14) * Update Rust build * Fix interfaces in architecture diagram (#17) * Fix KV interface provider * Fix Consensus interface provider * drop java attributes (#18) * tx pool remove unused import (#19) * ethbackend: add protocol version and client version (#20) * Add missing ethbackend I/F (#21) * Add interface versioning mechanism (#23) Add versioning in KV interface Co-authored-by: Artem Vorotnikov <artem@vorotnikov.me> * spec of tx pool method (#24) * spec of tx pool method (#25) * Update version.proto * Refactor interface versioning * Refactor interface versioning * Testing interface * Remove tree * Fix * Build testing protos * Fix * Fix * Update to the newer interfaces * Add ProtocolVersion and ClientVersion stubs * Hook up ProtocolVersion and ClientVersion * Remove service * Add compatibility checks for RPC daemon * Fix typos * Properly update DB schema version * Fix test * Add test for KV compatibility| * Info messages about compability for RPC daemon * DB schema version to be one key * Update release intructions Co-authored-by: Artem Vorotnikov <artem@vorotnikov.me> Co-authored-by: b00ris <b00ris@mail.ru> Co-authored-by: Alexey Sharp <alexeysharp@Alexeys-iMac.local> Co-authored-by: lightclient <14004106+lightclient@users.noreply.github.com> Co-authored-by: canepat <16927169+canepat@users.noreply.github.com> Co-authored-by: Alex Sharov <AskAlexSharov@gmail.com> Co-authored-by: canepat <tullio.canepa@gmail.com> Co-authored-by: Alex Sharp <alexsharp@Alexs-MacBook-Pro.local>
2021-04-24 15:46:29 +00:00
web3Impl := NewWeb3APIImpl(eth)
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 "txpool":
defaultAPIList = append(defaultAPIList, rpc.API{
Namespace: "txpool",
Public: true,
Service: TxPoolAPI(txpoolImpl),
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 "erigon":
defaultAPIList = append(defaultAPIList, rpc.API{
Namespace: "erigon",
Public: true,
Service: ErigonAPI(erigonImpl),
Version: "1.0",
})
}
}
return append(defaultAPIList, customAPIList...)
}