aboutsummaryrefslogtreecommitdiffstats
path: root/dex/blockproposer.go
diff options
context:
space:
mode:
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