aboutsummaryrefslogtreecommitdiffstats
path: root/dex/blockproposer.go
diff options
context:
space:
mode:
authorSonic <sonic@dexon.org>2019-03-19 20:12:58 +0800
committerWei-Ning Huang <w@byzantine-lab.io>2019-06-13 18:11:44 +0800
commite88b78cb0c2d3736d31a79de46e99461e26f5161 (patch)
treefecd6a43ccae9c6fdd6bc0b977062c4e00e007f0 /dex/blockproposer.go
parent061ed2c8187fe10e35e20e12945533f5c4fd6313 (diff)
downloadgo-tangerine-e88b78cb0c2d3736d31a79de46e99461e26f5161.tar
go-tangerine-e88b78cb0c2d3736d31a79de46e99461e26f5161.tar.gz
go-tangerine-e88b78cb0c2d3736d31a79de46e99461e26f5161.tar.bz2
go-tangerine-e88b78cb0c2d3736d31a79de46e99461e26f5161.tar.lz
go-tangerine-e88b78cb0c2d3736d31a79de46e99461e26f5161.tar.xz
go-tangerine-e88b78cb0c2d3736d31a79de46e99461e26f5161.tar.zst
go-tangerine-e88b78cb0c2d3736d31a79de46e99461e26f5161.zip
dex: fix start bp node with empty datadir (#278)
also modify some debug log
Diffstat (limited to 'dex/blockproposer.go')
-rw-r--r--dex/blockproposer.go13
1 files changed, 8 insertions, 5 deletions
diff --git a/dex/blockproposer.go b/dex/blockproposer.go
index bcc150747..5af08f6c4 100644
--- a/dex/blockproposer.go
+++ b/dex/blockproposer.go
@@ -87,7 +87,7 @@ func (b *blockProposer) Stop() {
defer b.mu.Unlock()
if atomic.LoadInt32(&b.running) == 1 {
- b.dex.protocolManager.isBlockProposer = false
+ b.dex.protocolManager.receiveEnabled = false
close(b.stopCh)
b.wg.Wait()
atomic.StoreInt32(&b.proposing, 0)
@@ -127,7 +127,6 @@ func (b *blockProposer) syncConsensus() (*dexCore.Consensus, error) {
// Feed the current block we have in local blockchain.
cb := b.dex.blockchain.CurrentBlock()
-
if cb.NumberU64() > 0 {
var block coreTypes.Block
if err := rlp.DecodeBytes(cb.Header().DexconMeta, &block); err != nil {
@@ -153,6 +152,9 @@ func (b *blockProposer) syncConsensus() (*dexCore.Consensus, error) {
// Sync all blocks in compaction chain to core.
_, coreHeight := db.GetCompactionChainTipInfo()
+ // Stop receiving block proposer message when syncing.
+ b.dex.protocolManager.receiveEnabled = false
+
Loop:
for {
currentBlock := b.dex.blockchain.CurrentBlock()
@@ -182,9 +184,6 @@ Loop:
}
}
- // Enable isBlockProposer flag to start receiving msg.
- b.dex.protocolManager.isBlockProposer = true
-
ch := make(chan core.ChainHeadEvent)
sub := b.dex.blockchain.SubscribeChainHeadEvent(ch)
defer sub.Unsubscribe()
@@ -208,6 +207,10 @@ ListenLoop:
log.Error("SyncBlocks fail", "err", err)
return nil, err
}
+ if !b.dex.protocolManager.receiveEnabled {
+ // Start receiving block proposer message.
+ b.dex.protocolManager.receiveEnabled = true
+ }
if synced {
log.Debug("Consensus core synced")
break ListenLoop