From f3a8bd79153cdce70a9d189c45aa3880a5548d70 Mon Sep 17 00:00:00 2001 From: Wei-Ning Huang Date: Thu, 22 Aug 2019 22:43:15 +0800 Subject: dex: minor fix to core block syncing --- dex/blockproposer.go | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'dex') diff --git a/dex/blockproposer.go b/dex/blockproposer.go index 0ba45b30a..486d4756f 100644 --- a/dex/blockproposer.go +++ b/dex/blockproposer.go @@ -148,7 +148,7 @@ func (b *blockProposer) syncConsensus() (*dexCore.Consensus, error) { blocksToSync := func(coreHeight, height uint64) []*coreTypes.Block { var blocks []*coreTypes.Block - for coreHeight < height { + for len(blocks) < 1024 && coreHeight < height { var block coreTypes.Block b := b.dex.blockchain.GetBlockByNumber(coreHeight + 1) if err := rlp.DecodeBytes(b.Header().DexconMeta, &block); err != nil { @@ -203,9 +203,11 @@ ListenLoop: for { select { case ev := <-ch: - blocks := blocksToSync(coreHeight, ev.Block.NumberU64()) - - if len(blocks) > 0 { + for { + blocks := blocksToSync(coreHeight, ev.Block.NumberU64()) + if len(blocks) == 0 { + break + } b.watchCat.Feed(blocks[len(blocks)-1].Position) log.Debug("Filling compaction chain", "num", len(blocks), "first", blocks[0].Position.Height, -- cgit