diff options
author | Wei-Ning Huang <w@dexon.org> | 2019-03-19 15:35:32 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-03-19 15:35:32 +0800 |
commit | 3a0ec5eaffa6e27e241e066c10a96ef64100afc4 (patch) | |
tree | a4e6aa233c4aeeef445a85f11a8323a121cac138 | |
parent | 937fd45d503e500fce424143a4873b8fa32d7b05 (diff) | |
download | dexon-3a0ec5eaffa6e27e241e066c10a96ef64100afc4.tar dexon-3a0ec5eaffa6e27e241e066c10a96ef64100afc4.tar.gz dexon-3a0ec5eaffa6e27e241e066c10a96ef64100afc4.tar.bz2 dexon-3a0ec5eaffa6e27e241e066c10a96ef64100afc4.tar.lz dexon-3a0ec5eaffa6e27e241e066c10a96ef64100afc4.tar.xz dexon-3a0ec5eaffa6e27e241e066c10a96ef64100afc4.tar.zst dexon-3a0ec5eaffa6e27e241e066c10a96ef64100afc4.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 |