aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWei-Ning Huang <w@dexon.org>2019-03-19 15:35:32 +0800
committerWei-Ning Huang <w@dexon.org>2019-04-09 21:32:58 +0800
commit4ae37d25a2bd79fa98a5e7845342b98133d2cc6f (patch)
treed1a8f5d48f4ce5fa9b9136a0abb3accc50ce4743
parentfff05d83302f6c168409e9e614cd9da7d43bc94a (diff)
downloaddexon-4ae37d25a2bd79fa98a5e7845342b98133d2cc6f.tar.gz
dexon-4ae37d25a2bd79fa98a5e7845342b98133d2cc6f.tar.zst
dexon-4ae37d25a2bd79fa98a5e7845342b98133d2cc6f.zip
dex: do not start watchcat when blockchain is empty (#273)
-rw-r--r--dex/blockproposer.go12
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