aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWei-Ning Huang <w@dexon.org>2019-03-17 14:28:19 +0800
committerWei-Ning Huang <w@dexon.org>2019-04-09 13:50:04 +0800
commit963c79c325e8f1c10321bb0c69ec32607c24d3ab (patch)
treed3bebdbff40faefda94fa99de15af99f6e6d6e37
parent74f23bef7863264e7ade5ca916a2504f835196ae (diff)
downloaddexon-963c79c325e8f1c10321bb0c69ec32607c24d3ab.tar.gz
dexon-963c79c325e8f1c10321bb0c69ec32607c24d3ab.tar.zst
dexon-963c79c325e8f1c10321bb0c69ec32607c24d3ab.zip
dex: properly start and stop the block proposer module (#264)
Stop blockproposer in the Stop() method of node service so the process doens't hang.
-rw-r--r--cmd/gdex/main.go3
-rw-r--r--dex/api.go8
-rw-r--r--dex/backend.go15
-rw-r--r--dex/handler.go4
4 files changed, 11 insertions, 19 deletions
diff --git a/cmd/gdex/main.go b/cmd/gdex/main.go
index 3796691ee..9b51f5ab8 100644
--- a/cmd/gdex/main.go
+++ b/cmd/gdex/main.go
@@ -370,8 +370,5 @@ func startNode(ctx *cli.Context, stack *node.Node) {
if err := stack.Service(&dexon); err != nil {
utils.Fatalf("Dexon service not running: %v", err)
}
- if err := dexon.StartProposing(); err != nil {
- utils.Fatalf("Failed to string proposing: %v", err)
- }
}
}
diff --git a/dex/api.go b/dex/api.go
index 23f98d7df..70976f071 100644
--- a/dex/api.go
+++ b/dex/api.go
@@ -131,14 +131,6 @@ func (api *PrivateAdminAPI) ImportChain(file string) (bool, error) {
return true, nil
}
-func (api *PrivateAdminAPI) StartProposing() error {
- return api.dex.StartProposing()
-}
-
-func (api *PrivateAdminAPI) StopProposing() {
- api.dex.StopProposing()
-}
-
func (api *PrivateAdminAPI) IsCoreSyncing() bool {
return api.dex.IsCoreSyncing()
}
diff --git a/dex/backend.go b/dex/backend.go
index 0f68163c0..e90c3ad10 100644
--- a/dex/backend.go
+++ b/dex/backend.go
@@ -251,6 +251,10 @@ func (s *Dexon) Start(srvr *p2p.Server) error {
}
// Start the networking layer and the light server if requested
s.protocolManager.Start(srvr, maxPeers)
+
+ if s.config.BlockProposerEnabled {
+ s.bp.Start()
+ }
return nil
}
@@ -260,17 +264,12 @@ func (s *Dexon) Stop() error {
if s.indexer != nil {
s.indexer.Stop()
}
+ if s.config.BlockProposerEnabled {
+ s.bp.Stop()
+ }
return nil
}
-func (s *Dexon) StartProposing() error {
- return s.bp.Start()
-}
-
-func (s *Dexon) StopProposing() {
- s.bp.Stop()
-}
-
func (s *Dexon) IsCoreSyncing() bool {
return s.bp.IsCoreSyncing()
}
diff --git a/dex/handler.go b/dex/handler.go
index ea04e6fbc..91d7360b2 100644
--- a/dex/handler.go
+++ b/dex/handler.go
@@ -310,6 +310,10 @@ func (pm *ProtocolManager) Stop() {
pm.txsSub.Unsubscribe() // quits txBroadcastLoop
pm.chainHeadSub.Unsubscribe()
+ if pm.isBlockProposer {
+ pm.finalizedBlockSub.Unsubscribe()
+ }
+
// Quit the sync loop.
// After this send has completed, no new peers will be accepted.
pm.noMorePeers <- struct{}{}