@@ -42,8 +42,7 @@ type Opt = func(val *Manager)
4242// AssertionManager works with the challenge manager suppplying information
4343// about assertions.
4444type AssertionManager interface {
45- Start (context.Context )
46- StopAndWait ()
45+ stopwaiter.StoppableChild
4746 LatestAgreedAssertion () protocol.AssertionHash
4847 SetRivalHandler (types.RivalHandler )
4948}
@@ -280,8 +279,7 @@ func (m *Manager) Start(ctx context.Context) {
280279 m .StopWaiter .Start (ctx , m )
281280 log .Info ("Started challenge manager" , "stakerAddress" , m .chain .StakerAddress ().Hex ())
282281
283- // Start the assertion manager on its own StopWaiter.
284- m .assertionManager .Start (m .GetContext ())
282+ m .StartAndTrackChild (m .assertionManager )
285283
286284 // Watcher tower and resolve modes don't monitor challenges.
287285 if m .mode == types .WatchTowerMode || m .mode == types .ResolveMode {
@@ -291,26 +289,13 @@ func (m *Manager) Start(ctx context.Context) {
291289 // Start watching for parent chain block events in the background.
292290 m .LaunchThread (m .listenForBlockEvents )
293291
294- // Start watching for ongoing chain events on its own StopWaiter.
295- m .watcher .Start (m .GetContext ())
292+ m .StartAndTrackChild (m .watcher )
296293
297294 if m .api != nil {
298- // Start the API server on its own StopWaiter.
299- m .api .Start (m .GetContext ())
295+ m .StartAndTrackChild (m .api )
300296 }
301297}
302298
303- func (m * Manager ) StopAndWait () {
304- // Stop children first so they can shut down gracefully before
305- // the parent context is cancelled.
306- if m .api != nil {
307- m .api .StopAndWait ()
308- }
309- m .watcher .StopAndWait ()
310- m .assertionManager .StopAndWait ()
311- m .StopWaiter .StopAndWait ()
312- }
313-
314299func (m * Manager ) listenForBlockEvents (ctx context.Context ) {
315300 // If the chain watcher has not yet scraped and caught up all BoLD
316301 // events up to the latest head, then we fire "block notification" events
0 commit comments