mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 10:52:25 +00:00
cmd/utils, eth/catalyst: terminate node wyen synctarget reached
This commit is contained in:
parent
48960d784b
commit
619649d6ea
2 changed files with 16 additions and 11 deletions
|
|
@ -1687,7 +1687,9 @@ func SetEthConfig(ctx *cli.Context, stack *node.Node, cfg *ethconfig.Config) {
|
|||
log.Debug("Sanitizing Go's GC trigger", "percent", int(gogc))
|
||||
godebug.SetGCPercent(int(gogc))
|
||||
|
||||
if ctx.IsSet(SyncModeFlag.Name) {
|
||||
if ctx.IsSet(SyncTargetFlag.Name) {
|
||||
cfg.SyncMode = downloader.FullSync // dev sync target forces full sync
|
||||
} else if ctx.IsSet(SyncModeFlag.Name) {
|
||||
cfg.SyncMode = *flags.GlobalTextMarshaler(ctx, SyncModeFlag.Name).(*downloader.SyncMode)
|
||||
}
|
||||
if ctx.IsSet(NetworkIdFlag.Name) {
|
||||
|
|
|
|||
|
|
@ -34,7 +34,8 @@ import (
|
|||
// This tester can be applied to different networks, no matter it's pre-merge or
|
||||
// post-merge, but only for full-sync.
|
||||
type FullSyncTester struct {
|
||||
api *ConsensusAPI
|
||||
stack *node.Node
|
||||
backend *eth.Ethereum
|
||||
target common.Hash
|
||||
closed chan struct{}
|
||||
wg sync.WaitGroup
|
||||
|
|
@ -44,7 +45,8 @@ type FullSyncTester struct {
|
|||
// stack for launching and stopping the service controlled by node.
|
||||
func RegisterFullSyncTester(stack *node.Node, backend *eth.Ethereum, target common.Hash) (*FullSyncTester, error) {
|
||||
cl := &FullSyncTester{
|
||||
api: newConsensusAPIWithoutHeartbeat(backend),
|
||||
stack: stack,
|
||||
backend: backend,
|
||||
target: target,
|
||||
closed: make(chan struct{}),
|
||||
}
|
||||
|
|
@ -60,7 +62,7 @@ func (tester *FullSyncTester) Start() error {
|
|||
|
||||
// Trigger beacon sync with the provided block hash as trusted
|
||||
// chain head.
|
||||
err := tester.api.eth.Downloader().BeaconDevSync(downloader.FullSync, tester.target, tester.closed)
|
||||
err := tester.backend.Downloader().BeaconDevSync(downloader.FullSync, tester.target, tester.closed)
|
||||
if err != nil {
|
||||
log.Info("Failed to trigger beacon sync", "err", err)
|
||||
}
|
||||
|
|
@ -72,11 +74,12 @@ func (tester *FullSyncTester) Start() error {
|
|||
select {
|
||||
case <-ticker.C:
|
||||
// Stop in case the target block is already stored locally.
|
||||
// TODO(somehow terminate the node stack if target is reached).
|
||||
if block := tester.api.eth.BlockChain().GetBlockByHash(tester.target); block != nil {
|
||||
if block := tester.backend.BlockChain().GetBlockByHash(tester.target); block != nil {
|
||||
log.Info("Full-sync target reached", "number", block.NumberU64(), "hash", block.Hash())
|
||||
go tester.stack.Close() // async since we need to close ourselves
|
||||
return
|
||||
}
|
||||
|
||||
case <-tester.closed:
|
||||
return
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue