2020-09-06 11:35:32 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"os"
|
|
|
|
|
2022-04-17 08:22:00 +00:00
|
|
|
"github.com/ledgerwatch/erigon-lib/common/dbg"
|
2021-06-11 08:34:37 +00:00
|
|
|
"github.com/ledgerwatch/erigon/params"
|
2022-01-20 07:34:50 +00:00
|
|
|
erigonapp "github.com/ledgerwatch/erigon/turbo/app"
|
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() {
|
2022-04-17 08:22:00 +00:00
|
|
|
defer func() {
|
|
|
|
panicResult := recover()
|
|
|
|
if panicResult == nil {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
log.Error("catch panic", "err", panicResult, "stack", dbg.Stack())
|
|
|
|
os.Exit(1)
|
|
|
|
}()
|
|
|
|
|
2022-01-20 07:34:50 +00:00
|
|
|
app := erigonapp.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
|
|
|
}
|
|
|
|
}
|