2019-12-02 13:47:00 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"os"
|
|
|
|
|
2020-09-05 20:58:51 +00:00
|
|
|
"github.com/ledgerwatch/turbo-geth/cmd/utils"
|
|
|
|
|
2020-08-19 11:46:20 +00:00
|
|
|
"github.com/ledgerwatch/turbo-geth/cmd/rpcdaemon/cli"
|
2019-12-02 13:47:00 +00:00
|
|
|
"github.com/ledgerwatch/turbo-geth/cmd/rpcdaemon/commands"
|
|
|
|
"github.com/ledgerwatch/turbo-geth/log"
|
2020-08-19 11:46:20 +00:00
|
|
|
"github.com/spf13/cobra"
|
2019-12-02 13:47:00 +00:00
|
|
|
)
|
|
|
|
|
2020-09-11 13:12:38 +00:00
|
|
|
var (
|
|
|
|
gitCommit string
|
|
|
|
)
|
|
|
|
|
2019-12-02 13:47:00 +00:00
|
|
|
func main() {
|
2020-08-19 11:46:20 +00:00
|
|
|
cmd, cfg := cli.RootCommand()
|
|
|
|
cmd.RunE = func(cmd *cobra.Command, args []string) error {
|
2020-08-20 03:52:27 +00:00
|
|
|
db, backend, err := cli.OpenDB(*cfg)
|
2020-08-19 11:46:20 +00:00
|
|
|
if err != nil {
|
|
|
|
log.Error("Could not connect to remoteDb", "error", err)
|
|
|
|
return nil
|
|
|
|
}
|
2019-12-02 13:47:00 +00:00
|
|
|
|
2020-08-20 03:52:27 +00:00
|
|
|
var apiList = commands.APIList(db, backend, *cfg, nil)
|
|
|
|
return cli.StartRpcServer(cmd.Context(), *cfg, apiList)
|
2019-12-02 13:47:00 +00:00
|
|
|
}
|
|
|
|
|
2020-09-11 13:12:38 +00:00
|
|
|
// Hacky way to get these strings into the commands package
|
|
|
|
commands.SetGitStrings(gitCommit)
|
|
|
|
|
2020-08-19 11:46:20 +00:00
|
|
|
if err := cmd.ExecuteContext(utils.RootContext()); err != nil {
|
|
|
|
log.Error(err.Error())
|
|
|
|
os.Exit(1)
|
|
|
|
}
|
2019-12-02 13:47:00 +00:00
|
|
|
}
|