mirror of
https://gitlab.com/pulsechaincom/erigon-pulse.git
synced 2025-01-08 12:01:20 +00:00
62 lines
1.6 KiB
Go
62 lines
1.6 KiB
Go
|
package erigon
|
||
|
|
||
|
import (
|
||
|
"fmt"
|
||
|
"os"
|
||
|
|
||
|
"github.com/ledgerwatch/erigon-lib/common/dbg"
|
||
|
"github.com/ledgerwatch/erigon/cmd/devnettest/rpcdaemon"
|
||
|
"github.com/ledgerwatch/erigon/params"
|
||
|
erigonapp "github.com/ledgerwatch/erigon/turbo/app"
|
||
|
erigoncli "github.com/ledgerwatch/erigon/turbo/cli"
|
||
|
"github.com/ledgerwatch/erigon/turbo/node"
|
||
|
"github.com/ledgerwatch/log/v3"
|
||
|
"github.com/urfave/cli"
|
||
|
)
|
||
|
|
||
|
const DevPeriod = 5
|
||
|
|
||
|
func RunNode() {
|
||
|
defer func() {
|
||
|
panicResult := recover()
|
||
|
if panicResult == nil {
|
||
|
return
|
||
|
}
|
||
|
|
||
|
log.Error("catch panic", "err", panicResult, "stack", dbg.Stack())
|
||
|
os.Exit(1)
|
||
|
}()
|
||
|
|
||
|
app := erigonapp.MakeApp(runDevnet, erigoncli.DefaultFlags) // change to erigoncli.DefaultFlags later on
|
||
|
customArgs := []string{"./build/bin/devnettest", "--datadir=./dev", "--chain=dev", "--mine", fmt.Sprintf("--dev.period=%d", DevPeriod), "--verbosity=0"}
|
||
|
if err := app.Run(customArgs); err != nil {
|
||
|
fmt.Fprintln(os.Stderr, err)
|
||
|
os.Exit(1)
|
||
|
}
|
||
|
}
|
||
|
|
||
|
func runDevnet(cliCtx *cli.Context) {
|
||
|
logger := log.New()
|
||
|
// initializing the node and providing the current git commit there
|
||
|
logger.Info("Build info", "git_branch", params.GitBranch, "git_tag", params.GitTag, "git_commit", params.GitCommit)
|
||
|
|
||
|
nodeCfg := node.NewNodConfigUrfave(cliCtx)
|
||
|
ethCfg := node.NewEthConfigUrfave(cliCtx, nodeCfg)
|
||
|
|
||
|
ethNode, err := node.New(nodeCfg, ethCfg, logger)
|
||
|
if err != nil {
|
||
|
log.Error("Devnet startup", "err", err)
|
||
|
return
|
||
|
}
|
||
|
err = ethNode.Serve()
|
||
|
if err != nil {
|
||
|
log.Error("error while serving a Devnet node", "err", err)
|
||
|
}
|
||
|
}
|
||
|
|
||
|
func StartProcess() {
|
||
|
fmt.Println("Starting erigon node and rpc daemon...")
|
||
|
go RunNode()
|
||
|
go rpcdaemon.RunDaemon()
|
||
|
}
|