@@ -34,21 +34,23 @@ import (
3434// This tester can be applied to different networks, no matter it's pre-merge or
3535// post-merge, but only for full-sync.
3636type FullSyncTester struct {
37- stack * node.Node
38- backend * eth.Ethereum
39- target common.Hash
40- closed chan struct {}
41- wg sync.WaitGroup
37+ stack * node.Node
38+ backend * eth.Ethereum
39+ target common.Hash
40+ closed chan struct {}
41+ wg sync.WaitGroup
42+ exitWhenSynced bool
4243}
4344
4445// RegisterFullSyncTester registers the full-sync tester service into the node
4546// stack for launching and stopping the service controlled by node.
46- func RegisterFullSyncTester (stack * node.Node , backend * eth.Ethereum , target common.Hash ) (* FullSyncTester , error ) {
47+ func RegisterFullSyncTester (stack * node.Node , backend * eth.Ethereum , target common.Hash , exitWhenSynced bool ) (* FullSyncTester , error ) {
4748 cl := & FullSyncTester {
48- stack : stack ,
49- backend : backend ,
50- target : target ,
51- closed : make (chan struct {}),
49+ stack : stack ,
50+ backend : backend ,
51+ target : target ,
52+ closed : make (chan struct {}),
53+ exitWhenSynced : exitWhenSynced ,
5254 }
5355 stack .RegisterLifecycle (cl )
5456 return cl , nil
@@ -76,7 +78,11 @@ func (tester *FullSyncTester) Start() error {
7678 // Stop in case the target block is already stored locally.
7779 if block := tester .backend .BlockChain ().GetBlockByHash (tester .target ); block != nil {
7880 log .Info ("Full-sync target reached" , "number" , block .NumberU64 (), "hash" , block .Hash ())
79- go tester .stack .Close () // async since we need to close ourselves
81+
82+ if tester .exitWhenSynced {
83+ go tester .stack .Close () // async since we need to close ourselves
84+ log .Info ("Terminating the node" )
85+ }
8086 return
8187 }
8288
0 commit comments