aboutsummaryrefslogtreecommitdiffstats
path: root/dex
diff options
context:
space:
mode:
authorWei-Ning Huang <w@byzantine-lab.io>2019-08-28 17:40:26 +0800
committerWei-Ning Huang <w@byzantine-lab.io>2019-09-17 16:57:31 +0800
commitdff8a1eb364bc522c06256b24b46913866a06110 (patch)
tree9cc812c1f1117c7e51a0fa6725adbba7b846efe1 /dex
parent3de6c17ecea5ee7efc6ab4b442b0aa9b8c590eea (diff)
downloadgo-tangerine-dff8a1eb364bc522c06256b24b46913866a06110.tar.gz
go-tangerine-dff8a1eb364bc522c06256b24b46913866a06110.tar.zst
go-tangerine-dff8a1eb364bc522c06256b24b46913866a06110.zip
dex: improve block proposer syncing process
Diffstat (limited to 'dex')
-rw-r--r--dex/blockproposer.go35
1 files changed, 16 insertions, 19 deletions
diff --git a/dex/blockproposer.go b/dex/blockproposer.go
index 486d4756f..762707aac 100644
--- a/dex/blockproposer.go
+++ b/dex/blockproposer.go
@@ -132,23 +132,9 @@ func (b *blockProposer) syncConsensus() (*dexCore.Consensus, error) {
consensusSync := syncer.NewConsensus(cb.NumberU64(), b.dMoment, b.dex.app,
b.dex.governance, db, b.dex.network, privkey, log.Root())
- // Start the watchCat.
- b.watchCat.Start()
- defer b.watchCat.Stop()
- log.Info("Started sync watchCat")
-
- // Feed the current block we have in local blockchain.
- 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)
- }
-
blocksToSync := func(coreHeight, height uint64) []*coreTypes.Block {
var blocks []*coreTypes.Block
- for len(blocks) < 1024 && coreHeight < height {
+ for len(blocks) < 2048 && coreHeight < height {
var block coreTypes.Block
b := b.dex.blockchain.GetBlockByNumber(coreHeight + 1)
if err := rlp.DecodeBytes(b.Header().DexconMeta, &block); err != nil {
@@ -166,7 +152,7 @@ func (b *blockProposer) syncConsensus() (*dexCore.Consensus, error) {
Loop:
for {
currentBlock := b.dex.blockchain.CurrentBlock()
- log.Debug("Syncing compaction chain", "core height", coreHeight,
+ log.Info("Syncing compaction chain", "core height", coreHeight,
"height", currentBlock.NumberU64())
blocks := blocksToSync(coreHeight, currentBlock.NumberU64())
@@ -174,7 +160,6 @@ Loop:
log.Debug("No new block to sync", "current", currentBlock.NumberU64())
break Loop
}
- b.watchCat.Feed(blocks[len(blocks)-1].Position)
log.Debug("Filling compaction chain", "num", len(blocks),
"first", blocks[0].Position.Height,
@@ -192,12 +177,24 @@ Loop:
}
}
+ // Start the watchCat.
+ b.watchCat.Start()
+ defer b.watchCat.Stop()
+ log.Info("Started sync WatchCat")
+
+ // Feed the current block we have in local blockchain.
+ 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)
+ }
+
ch := make(chan core.ChainHeadEvent)
sub := b.dex.blockchain.SubscribeChainHeadEvent(ch)
defer sub.Unsubscribe()
- log.Debug("Listen chain head event until synced")
-
// Listen chain head event until synced.
ListenLoop:
for {