aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWei-Ning Huang <w@dexon.org>2019-03-17 20:14:41 +0800
committerGitHub <noreply@github.com>2019-03-17 20:14:41 +0800
commit7b1113e5231d0841c5543228d35b12a83925977a (patch)
tree69bd790fe4fd87ef8dcfeb72fd33538199bd15cb
parent0f080723f00b24843f240ac3d603397e424f4249 (diff)
downloaddexon-7b1113e5231d0841c5543228d35b12a83925977a.tar
dexon-7b1113e5231d0841c5543228d35b12a83925977a.tar.gz
dexon-7b1113e5231d0841c5543228d35b12a83925977a.tar.bz2
dexon-7b1113e5231d0841c5543228d35b12a83925977a.tar.lz
dexon-7b1113e5231d0841c5543228d35b12a83925977a.tar.xz
dexon-7b1113e5231d0841c5543228d35b12a83925977a.tar.zst
dexon-7b1113e5231d0841c5543228d35b12a83925977a.zip
dex: properly shutdown protocol stack (#267)
-rw-r--r--dex/backend.go11
-rw-r--r--dex/blockproposer.go3
-rw-r--r--dex/handler.go4
3 files changed, 12 insertions, 6 deletions
diff --git a/dex/backend.go b/dex/backend.go
index e90c3ad10..f1b0012a2 100644
--- a/dex/backend.go
+++ b/dex/backend.go
@@ -259,14 +259,19 @@ func (s *Dexon) Start(srvr *p2p.Server) error {
}
func (s *Dexon) Stop() error {
+ s.bloomIndexer.Close()
+ s.blockchain.Stop()
+ s.engine.Close()
+ s.protocolManager.Stop()
+ s.txPool.Stop()
+ s.eventMux.Stop()
s.bp.Stop()
s.app.Stop()
if s.indexer != nil {
s.indexer.Stop()
}
- if s.config.BlockProposerEnabled {
- s.bp.Stop()
- }
+ s.chainDb.Close()
+ close(s.shutdownChan)
return nil
}
diff --git a/dex/blockproposer.go b/dex/blockproposer.go
index 6c1de818a..58e6eafee 100644
--- a/dex/blockproposer.go
+++ b/dex/blockproposer.go
@@ -79,10 +79,10 @@ func (b *blockProposer) run(c *dexCore.Consensus) {
atomic.StoreInt32(&b.proposing, 1)
<-b.stopCh
log.Debug("Block proposer receive stop signal")
- c.Stop()
}
func (b *blockProposer) Stop() {
+ log.Info("Stopping block proposer")
b.mu.Lock()
defer b.mu.Unlock()
@@ -92,6 +92,7 @@ func (b *blockProposer) Stop() {
b.wg.Wait()
atomic.StoreInt32(&b.proposing, 0)
}
+ log.Info("Block proposer stopped")
}
func (b *blockProposer) IsCoreSyncing() bool {
diff --git a/dex/handler.go b/dex/handler.go
index 91d7360b2..e887d54d9 100644
--- a/dex/handler.go
+++ b/dex/handler.go
@@ -305,7 +305,7 @@ func (pm *ProtocolManager) Start(srvr p2pServer, maxPeers int) {
}
func (pm *ProtocolManager) Stop() {
- log.Info("Stopping Ethereum protocol")
+ log.Info("Stopping DEXON protocol")
pm.txsSub.Unsubscribe() // quits txBroadcastLoop
pm.chainHeadSub.Unsubscribe()
@@ -330,7 +330,7 @@ func (pm *ProtocolManager) Stop() {
// Wait for all peer handler goroutines and the loops to come down.
pm.wg.Wait()
- log.Info("Ethereum protocol stopped")
+ log.Info("DEXON protocol stopped")
}
func (pm *ProtocolManager) ReceiveChan() <-chan interface{} {