server: re-introduce the quit channel to the server

This commit re-introduces the quit channel to the server as an upcoming
addition needs to synchronize its shutdown with the lifetime of the
server.
This commit is contained in:
Olaoluwa Osuntokun 2017-08-10 21:18:57 -07:00
parent 947544753f
commit bee7ed7758
No known key found for this signature in database
GPG Key ID: 3D0A94DB79743DF5

View File

@ -82,8 +82,8 @@ type server struct {
// advertised to other nodes.
globalFeatures *lnwire.FeatureVector
// localFeatures is an feature vector which represent the features which
// only affect the protocol between these two nodes.
// localFeatures is an feature vector which represent the features
// which only affect the protocol between these two nodes.
localFeatures *lnwire.FeatureVector
// currentNodeAnn is the node announcement that has been broadcast to
@ -91,6 +91,8 @@ type server struct {
// changed since last start.
currentNodeAnn *lnwire.NodeAnnouncement
quit chan struct{}
wg sync.WaitGroup
}
@ -137,6 +139,8 @@ func newServer(listenAddrs []string, chanDB *channeldb.DB, cc *chainControl,
globalFeatures: globalFeatures,
localFeatures: localFeatures,
quit: make(chan struct{}),
}
// If the debug HTLC flag is on, then we invoice a "master debug"
@ -364,6 +368,8 @@ func (s *server) Stop() error {
return nil
}
close(s.quit)
// Shutdown the wallet, funding manager, and the rpc server.
s.cc.chainNotifier.Stop()
s.chanRouter.Stop()