fix initial leader bootstrap issue

pull/1694/head
chao 5 years ago
parent b32726d651
commit 07a093fdab
  1. 5
      consensus/consensus_v2.go

@ -1027,7 +1027,8 @@ func (consensus *Consensus) tryCatchup() {
func (consensus *Consensus) Start(blockChannel chan *types.Block, stopChan chan struct{}, stoppedChan chan struct{}, startChannel chan struct{}) {
go func() {
toStart := false
if consensus.IsLeader() {
isInitialLeader := consensus.IsLeader()
if isInitialLeader {
utils.Logger().Info().Time("time", time.Now()).Msg("[ConsensusMainLoop] Waiting for consensus start")
// send a signal to indicate it's ready to run consensus
@ -1052,7 +1053,7 @@ func (consensus *Consensus) Start(blockChannel chan *types.Block, stopChan chan
for {
select {
case <-ticker.C:
if toStart == false {
if toStart == false && isInitialLeader {
continue
}
for k, v := range consensus.consensusTimeout {

Loading…
Cancel
Save