diff options
author | Wei-Ning Huang <w@dexon.org> | 2019-03-19 15:35:32 +0800 |
---|---|---|
committer | Wei-Ning Huang <w@byzantine-lab.io> | 2019-06-12 17:27:23 +0800 |
commit | 55e22571a1cd5ef5d27a29ab1b0ecfb1b78cb264 (patch) | |
tree | 60470e2831887c855ce6892865b142170ea8433a | |
parent | 3dadb841289a41303f84ce96a0478a4f3cb8364c (diff) | |
download | go-tangerine-55e22571a1cd5ef5d27a29ab1b0ecfb1b78cb264.tar go-tangerine-55e22571a1cd5ef5d27a29ab1b0ecfb1b78cb264.tar.gz go-tangerine-55e22571a1cd5ef5d27a29ab1b0ecfb1b78cb264.tar.bz2 go-tangerine-55e22571a1cd5ef5d27a29ab1b0ecfb1b78cb264.tar.lz go-tangerine-55e22571a1cd5ef5d27a29ab1b0ecfb1b78cb264.tar.xz go-tangerine-55e22571a1cd5ef5d27a29ab1b0ecfb1b78cb264.tar.zst go-tangerine-55e22571a1cd5ef5d27a29ab1b0ecfb1b78cb264.zip |
dex: do not start watchcat when blockchain is empty (#273)
-rw-r--r-- | dex/blockproposer.go | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/dex/blockproposer.go b/dex/blockproposer.go index 63d424ab6..bcc150747 100644 --- a/dex/blockproposer.go +++ b/dex/blockproposer.go @@ -121,16 +121,20 @@ func (b *blockProposer) syncConsensus() (*dexCore.Consensus, error) { // Start the watchCat. log.Info("Starting sync watchCat ...") + b.watchCat.Start() defer b.watchCat.Stop() // Feed the current block we have in local blockchain. cb := b.dex.blockchain.CurrentBlock() - var block coreTypes.Block - if err := rlp.DecodeBytes(cb.Header().DexconMeta, &block); err != nil { - panic(err) + + if cb.NumberU64() > 0 { + var block coreTypes.Block + if err := rlp.DecodeBytes(cb.Header().DexconMeta, &block); err != nil { + panic(err) + } + b.watchCat.Feed(block.Position) } - b.watchCat.Feed(block.Position) blocksToSync := func(coreHeight, height uint64) []*coreTypes.Block { var blocks []*coreTypes.Block |