diff options
author | Sonic <sonic@dexon.org> | 2019-03-20 14:48:21 +0800 |
---|---|---|
committer | Wei-Ning Huang <w@byzantine-lab.io> | 2019-06-13 18:11:44 +0800 |
commit | 1eacbcbe3c890238da49fcfdddc151a5b7748265 (patch) | |
tree | 487092e55cecceaf8b23b1df17d330c26b574ae1 /dex/blockproposer.go | |
parent | a7d069aae1a4bc237a9a3a0f10efeba77c473bcb (diff) | |
download | go-tangerine-1eacbcbe3c890238da49fcfdddc151a5b7748265.tar go-tangerine-1eacbcbe3c890238da49fcfdddc151a5b7748265.tar.gz go-tangerine-1eacbcbe3c890238da49fcfdddc151a5b7748265.tar.bz2 go-tangerine-1eacbcbe3c890238da49fcfdddc151a5b7748265.tar.lz go-tangerine-1eacbcbe3c890238da49fcfdddc151a5b7748265.tar.xz go-tangerine-1eacbcbe3c890238da49fcfdddc151a5b7748265.tar.zst go-tangerine-1eacbcbe3c890238da49fcfdddc151a5b7748265.zip |
dex: ignore acceptableDist when force synchronise (#285)
Diffstat (limited to 'dex/blockproposer.go')
-rw-r--r-- | dex/blockproposer.go | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/dex/blockproposer.go b/dex/blockproposer.go index 5af08f6c4..63aaa5b51 100644 --- a/dex/blockproposer.go +++ b/dex/blockproposer.go @@ -18,6 +18,10 @@ import ( "github.com/dexon-foundation/dexon/rlp" ) +var ( + forceSyncTimeout = 20 * time.Second +) + type blockProposer struct { mu sync.Mutex running int32 @@ -223,6 +227,14 @@ ListenLoop: case <-b.stopCh: log.Debug("Early stop, before consensus core can run") return nil, errors.New("early stop") + case <-time.After(forceSyncTimeout): + log.Debug("no new chain head for a while") + if p := b.dex.protocolManager.peers.BestPeer(); p != nil { + log.Debug("try force sync with peer", "id", p.id) + b.dex.protocolManager.synchronise(p, true) + } else { + log.Debug("no peer to sync") + } case <-b.watchCat.Meow(): log.Info("WatchCat signaled to stop syncing") |