aboutsummaryrefslogtreecommitdiffstats
path: root/dex/backend.go
diff options
context:
space:
mode:
authorWei-Ning Huang <w@dexon.org>2019-03-21 16:27:57 +0800
committerWei-Ning Huang <w@byzantine-lab.io>2019-06-13 18:11:44 +0800
commit33f98f535d3f79d9d915ac57255aeee5d83ef81d (patch)
tree9c1e537923421b171b39e7becc5ea9d17823cfdd /dex/backend.go
parent3155f92f8f6c8018877c715c9b58bfbe19bfb8ea (diff)
downloadgo-tangerine-33f98f535d3f79d9d915ac57255aeee5d83ef81d.tar
go-tangerine-33f98f535d3f79d9d915ac57255aeee5d83ef81d.tar.gz
go-tangerine-33f98f535d3f79d9d915ac57255aeee5d83ef81d.tar.bz2
go-tangerine-33f98f535d3f79d9d915ac57255aeee5d83ef81d.tar.lz
go-tangerine-33f98f535d3f79d9d915ac57255aeee5d83ef81d.tar.xz
go-tangerine-33f98f535d3f79d9d915ac57255aeee5d83ef81d.tar.zst
go-tangerine-33f98f535d3f79d9d915ac57255aeee5d83ef81d.zip
dex: fix fast sync in BP mode (#291)
Start blockproposer only after fast sync is completed (received ChainHead event), so watchcat is not falsely triggered.
Diffstat (limited to 'dex/backend.go')
-rw-r--r--dex/backend.go15
1 files changed, 14 insertions, 1 deletions
diff --git a/dex/backend.go b/dex/backend.go
index f1b0012a2..29ac42906 100644
--- a/dex/backend.go
+++ b/dex/backend.go
@@ -253,7 +253,20 @@ func (s *Dexon) Start(srvr *p2p.Server) error {
s.protocolManager.Start(srvr, maxPeers)
if s.config.BlockProposerEnabled {
- s.bp.Start()
+ go func() {
+ // Since we might be in fast sync mode when started. wait for
+ // ChainHeadEvent before starting blockproposer, or else we will trigger
+ // watchcat.
+ if s.config.SyncMode == downloader.FastSync &&
+ s.blockchain.CurrentBlock().NumberU64() == 0 {
+ ch := make(chan core.ChainHeadEvent)
+ sub := s.blockchain.SubscribeChainHeadEvent(ch)
+ defer sub.Unsubscribe()
+
+ <-ch
+ }
+ s.bp.Start()
+ }()
}
return nil
}