@@ -34,21 +34,23 @@ import (
34
34
// This tester can be applied to different networks, no matter it's pre-merge or
35
35
// post-merge, but only for full-sync.
36
36
type 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
42
43
}
43
44
44
45
// RegisterFullSyncTester registers the full-sync tester service into the node
45
46
// 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 ) {
47
48
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 ,
52
54
}
53
55
stack .RegisterLifecycle (cl )
54
56
return cl , nil
@@ -76,7 +78,11 @@ func (tester *FullSyncTester) Start() error {
76
78
// Stop in case the target block is already stored locally.
77
79
if block := tester .backend .BlockChain ().GetBlockByHash (tester .target ); block != nil {
78
80
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
+ }
80
86
return
81
87
}
82
88
0 commit comments