Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion chains/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,8 @@ type manager struct {
// processed.
chainCreatorShutdownCh chan struct{}
chainCreatorExited sync.WaitGroup
context context.Context
cancelContext context.CancelFunc

chainsLock sync.Mutex
// Key: Chain's ID
Expand Down Expand Up @@ -324,7 +326,11 @@ func New(config *ManagerConfig) (Manager, error) {
return nil, err
}

ctx, cancelContext := context.WithCancel(context.Background())

return &manager{
context: ctx,
cancelContext: cancelContext,
Aliaser: ids.NewAliaser(),
ManagerConfig: *config,
chains: make(map[ids.ID]handler.Handler),
Expand Down Expand Up @@ -468,7 +474,7 @@ func (m *manager) createChain(chainParams ChainParameters) {

// Tell the chain to start processing messages.
// If the X, P, or C Chain panics, do not attempt to recover
chain.Handler.Start(context.TODO(), !m.CriticalChains.Contains(chainParams.ID))
chain.Handler.Start(m.context, !m.CriticalChains.Contains(chainParams.ID))
}

// Create a chain
Expand Down Expand Up @@ -1523,6 +1529,7 @@ func (m *manager) Shutdown() {
m.Log.Info("shutting down chain manager")
m.chainsQueue.Close()
close(m.chainCreatorShutdownCh)
m.cancelContext()
m.chainCreatorExited.Wait()
m.ManagerConfig.Router.Shutdown(context.TODO())
}
Expand Down
Loading