diff options
author | Wei-Ning Huang <w@dexon.org> | 2019-03-19 15:35:32 +0800 |
---|---|---|
committer | Wei-Ning Huang <w@dexon.org> | 2019-04-09 21:32:58 +0800 |
commit | 4ae37d25a2bd79fa98a5e7845342b98133d2cc6f (patch) | |
tree | d1a8f5d48f4ce5fa9b9136a0abb3accc50ce4743 | |
parent | fff05d83302f6c168409e9e614cd9da7d43bc94a (diff) | |
download | go-tangerine-4ae37d25a2bd79fa98a5e7845342b98133d2cc6f.tar go-tangerine-4ae37d25a2bd79fa98a5e7845342b98133d2cc6f.tar.gz go-tangerine-4ae37d25a2bd79fa98a5e7845342b98133d2cc6f.tar.bz2 go-tangerine-4ae37d25a2bd79fa98a5e7845342b98133d2cc6f.tar.lz go-tangerine-4ae37d25a2bd79fa98a5e7845342b98133d2cc6f.tar.xz go-tangerine-4ae37d25a2bd79fa98a5e7845342b98133d2cc6f.tar.zst go-tangerine-4ae37d25a2bd79fa98a5e7845342b98133d2cc6f.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 |