2020-09-06 11:35:32 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"os"
|
|
|
|
|
2021-06-13 16:41:39 +00:00
|
|
|
"github.com/ledgerwatch/erigon/common/debug"
|
2021-06-11 08:34:37 +00:00
|
|
|
"github.com/ledgerwatch/erigon/params"
|
2021-05-26 10:35:39 +00:00
|
|
|
erigoncli "github.com/ledgerwatch/erigon/turbo/cli"
|
2021-05-20 18:25:53 +00:00
|
|
|
"github.com/ledgerwatch/erigon/turbo/node"
|
2021-07-29 10:23:23 +00:00
|
|
|
"github.com/ledgerwatch/log/v3"
|
2020-09-06 11:35:32 +00:00
|
|
|
"github.com/urfave/cli"
|
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
2021-06-22 10:09:45 +00:00
|
|
|
defer debug.LogPanic()
|
2021-05-26 10:35:39 +00:00
|
|
|
app := erigoncli.MakeApp(runErigon, erigoncli.DefaultFlags)
|
2020-09-06 11:35:32 +00:00
|
|
|
if err := app.Run(os.Args); err != nil {
|
|
|
|
fmt.Fprintln(os.Stderr, err)
|
|
|
|
os.Exit(1)
|
|
|
|
}
|
|
|
|
}
|
2020-10-06 19:25:01 +00:00
|
|
|
|
2021-05-26 10:35:39 +00:00
|
|
|
func runErigon(cliCtx *cli.Context) {
|
2021-07-28 02:47:38 +00:00
|
|
|
logger := log.New()
|
2020-09-21 14:10:25 +00:00
|
|
|
// initializing the node and providing the current git commit there
|
2021-07-28 02:47:38 +00:00
|
|
|
logger.Info("Build info", "git_branch", params.GitBranch, "git_tag", params.GitTag, "git_commit", params.GitCommit)
|
2021-07-04 07:50:32 +00:00
|
|
|
nodeCfg := node.NewNodConfigUrfave(cliCtx)
|
|
|
|
ethCfg := node.NewEthConfigUrfave(cliCtx, nodeCfg)
|
2020-09-06 11:35:32 +00:00
|
|
|
|
2021-07-31 05:24:20 +00:00
|
|
|
ethNode, err := node.New(nodeCfg, ethCfg, logger)
|
2020-09-06 11:35:32 +00:00
|
|
|
if err != nil {
|
2021-07-31 05:24:20 +00:00
|
|
|
log.Error("Erigon startup", "err", err)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
err = ethNode.Serve()
|
|
|
|
if err != nil {
|
|
|
|
log.Error("error while serving an Erigon node", "err", err)
|
2020-09-06 11:35:32 +00:00
|
|
|
}
|
|
|
|
}
|