mirror of
https://gitlab.com/pulsechaincom/erigon-pulse.git
synced 2025-01-05 18:42:19 +00:00
565a4250d6
* save state * snapshot update works * save state * snapshot migrator * tx test * save state * migrations stages refactor * refactor snapshot migrator * compilation fixed * integrate snapshot migrator * goerli sync headers * debug async snapshotter on goerly * move verify headers, remove experiments, fix remove old snapshot * save state * refactor snapshotsync injection * fix deadlock * replace snapshot generation stage logic to migrate method * change done for body snapshot * clean * clean&&change deleted value * clean * fix hash len * fix hash len * remove one of wrap methods, add remove snapshots on start * add err check * fix shadowing * stages unwind order debug * matryoshka experiments * steam test * fix build * fix test * fix lint * fix test * fix test datarace * add get test * return timeout * fix mdbx overlap * fix after merge * change epoch size * clean todo * fix * return testdata * added return from sndownloader gorutine * fix review comments * Fix * More info Co-authored-by: Alex Sharp <alexsharp@Alexs-MacBook-Pro.local>
76 lines
2.1 KiB
Go
76 lines
2.1 KiB
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"net"
|
|
"os"
|
|
"unsafe"
|
|
|
|
"github.com/ledgerwatch/turbo-geth/cmd/utils"
|
|
"github.com/ledgerwatch/turbo-geth/eth/stagedsync"
|
|
"github.com/ledgerwatch/turbo-geth/log"
|
|
turbocli "github.com/ledgerwatch/turbo-geth/turbo/cli"
|
|
"github.com/ledgerwatch/turbo-geth/turbo/node"
|
|
"github.com/ledgerwatch/turbo-geth/turbo/silkworm"
|
|
"github.com/urfave/cli"
|
|
)
|
|
|
|
var (
|
|
// gitCommit is injected through the build flags (see Makefile)
|
|
gitCommit string
|
|
gitBranch string
|
|
)
|
|
|
|
func main() {
|
|
// creating a turbo-api app with all defaults
|
|
app := turbocli.MakeApp(runTurboGeth, turbocli.DefaultFlags)
|
|
if err := app.Run(os.Args); err != nil {
|
|
fmt.Fprintln(os.Stderr, err)
|
|
os.Exit(1)
|
|
}
|
|
}
|
|
|
|
func runTurboGeth(cliCtx *cli.Context) {
|
|
silkwormPath := cliCtx.String(turbocli.SilkwormFlag.Name)
|
|
var silkwormExecutionFunc unsafe.Pointer
|
|
if silkwormPath != "" {
|
|
var err error
|
|
silkwormExecutionFunc, err = silkworm.LoadExecutionFunctionPointer(silkwormPath)
|
|
if err != nil {
|
|
panic(fmt.Errorf("failed to load Silkworm dynamic library: %v", err))
|
|
}
|
|
}
|
|
|
|
var sync *stagedsync.StagedSync
|
|
if cliCtx.Bool(turbocli.SnapshotDatabaseLayoutFlag.Name) {
|
|
sync = stagedsync.New(
|
|
stagedsync.WithSnapshotsStages(),
|
|
stagedsync.UnwindOrderWithSnapshots(),
|
|
stagedsync.OptionalParameters{SilkwormExecutionFunc: silkwormExecutionFunc},
|
|
)
|
|
} else {
|
|
// creating staged sync with all default parameters
|
|
sync = stagedsync.New(
|
|
stagedsync.DefaultStages(),
|
|
stagedsync.DefaultUnwindOrder(),
|
|
stagedsync.OptionalParameters{SilkwormExecutionFunc: silkwormExecutionFunc},
|
|
)
|
|
}
|
|
|
|
ctx, _ := utils.RootContext()
|
|
|
|
// initializing the node and providing the current git commit there
|
|
log.Info("Build info", "git_branch", gitBranch, "git_commit", gitCommit)
|
|
tg := node.New(cliCtx, sync, node.Params{GitCommit: gitCommit, GitBranch: gitBranch})
|
|
tg.SetP2PListenFunc(func(network, addr string) (net.Listener, error) {
|
|
var lc net.ListenConfig
|
|
return lc.Listen(ctx, network, addr)
|
|
})
|
|
// running the node
|
|
err := tg.Serve()
|
|
|
|
if err != nil {
|
|
log.Error("error while serving a turbo-geth node", "err", err)
|
|
}
|
|
}
|