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