diff options
author | Sonic <sonic@dexon.org> | 2018-12-27 16:25:45 +0800 |
---|---|---|
committer | Wei-Ning Huang <w@byzantine-lab.io> | 2019-06-12 17:27:20 +0800 |
commit | a7bb33e5dba4f4b24a848c64954bf1659583e5a4 (patch) | |
tree | 22c15d0d79007844537575f93aea88f85773cf90 /dex | |
parent | 31e96869300a9b5e12e5eac9f47e6f1985e8894b (diff) | |
download | go-tangerine-a7bb33e5dba4f4b24a848c64954bf1659583e5a4.tar go-tangerine-a7bb33e5dba4f4b24a848c64954bf1659583e5a4.tar.gz go-tangerine-a7bb33e5dba4f4b24a848c64954bf1659583e5a4.tar.bz2 go-tangerine-a7bb33e5dba4f4b24a848c64954bf1659583e5a4.tar.lz go-tangerine-a7bb33e5dba4f4b24a848c64954bf1659583e5a4.tar.xz go-tangerine-a7bb33e5dba4f4b24a848c64954bf1659583e5a4.tar.zst go-tangerine-a7bb33e5dba4f4b24a848c64954bf1659583e5a4.zip |
dex/downloader: fix bug when syncing (#106)
Since blocks will interleave around round change, we will probably need
to verify blocks at previous round.
Diffstat (limited to 'dex')
-rw-r--r-- | dex/downloader/downloader.go | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/dex/downloader/downloader.go b/dex/downloader/downloader.go index 809fe7e4a..6ff8c122e 100644 --- a/dex/downloader/downloader.go +++ b/dex/downloader/downloader.go @@ -480,9 +480,9 @@ func (d *Downloader) syncWithPeer(p *peerConnection, hash common.Hash, number ui return fmt.Errorf("origin header not exists, number: %d", origin) } - // prepare state origin - 2 + // prepare state origin - 3 d.gov = newGovernance(govState) - for i := uint64(0); i < 3; i++ { + for i := uint64(0); i < 4; i++ { if originHeader.Round >= i { h := d.gov.GetRoundHeight(originHeader.Round - i) s, err := d.lightchain.GetGovStateByNumber(h) @@ -494,6 +494,17 @@ func (d *Downloader) syncWithPeer(p *peerConnection, hash common.Hash, number ui } d.verifierCache = dexCore.NewTSigVerifierCache(d.gov, 5) + + // warm up verifierCache + if originHeader.Round > 0 { + ok, err := d.verifierCache.Update(originHeader.Round - 1) + if err != nil { + return err + } + if !ok { + return fmt.Errorf("can not update verifier cache") + } + } } // Initiate the sync using a concurrent header and content retrieval algorithm |