aboutsummaryrefslogtreecommitdiffstats
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
parent3de6c17ecea5ee7efc6ab4b442b0aa9b8c590eea (diff)
downloadgo-tangerine-dff8a1eb364bc522c06256b24b46913866a06110.tar
go-tangerine-dff8a1eb364bc522c06256b24b46913866a06110.tar.gz
go-tangerine-dff8a1eb364bc522c06256b24b46913866a06110.tar.bz2
go-tangerine-dff8a1eb364bc522c06256b24b46913866a06110.tar.lz
go-tangerine-dff8a1eb364bc522c06256b24b46913866a06110.tar.xz
go-tangerine-dff8a1eb364bc522c06256b24b46913866a06110.tar.zst
go-tangerine-dff8a1eb364bc522c06256b24b46913866a06110.zip
dex: improve block proposer syncing process
-rw-r--r--dex/blockproposer.go35
-rw-r--r--vendor/vendor.json2
2 files changed, 17 insertions, 20 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 {
diff --git a/vendor/vendor.json b/vendor/vendor.json
index 89e3a539d..eb3bca6ef 100644
--- a/vendor/vendor.json
+++ b/vendor/vendor.json
@@ -727,7 +727,7 @@
"versionExact": "master"
},
{
- "checksumSHA1": "WUtiTpef7+yqS9ptOUgC8bQaaAM=",
+ "checksumSHA1": "O6B/sUzXOMSVYasxf3AnuTE1qG4=",
"path": "github.com/tangerine-network/tangerine-consensus/core/utils",
"revision": "1eecef2512d9c8a2bd3c0ef4af7a7b830fa30a0f",
"revisionTime": "2019-09-16T06:50:28Z",