@@ -67,6 +67,7 @@ type cmtLogImpl struct {
6767 varConsInsts VarConsInsts // The main algorithm.
6868 suspended bool // Is this committee currently suspended?
6969 output Output // The current output.
70+ first bool // A workaround to senf the first nextLI messages.
7071 asGPA gpa.GPA // This object, just with all the needed wrappers.
7172 log * logger.Logger
7273}
@@ -135,6 +136,7 @@ func New(
135136 varConsInsts : nil , // Set bellow.
136137 suspended : true ,
137138 output : nil ,
139+ first : true ,
138140 log : log ,
139141 }
140142 persistLIFunc := func (li LogIndex ) {
@@ -179,8 +181,7 @@ func (cl *cmtLogImpl) Input(input gpa.Input) gpa.OutMessages {
179181 case * inputConsensusTimeout :
180182 return cl .handleInputConsensusTimeout (input )
181183 case * inputCanPropose :
182- cl .handleInputCanPropose ()
183- return nil
184+ return cl .handleInputCanPropose ()
184185 case * inputSuspend :
185186 cl .handleInputSuspend ()
186187 return nil
@@ -224,8 +225,19 @@ func (cl *cmtLogImpl) handleInputConsensusTimeout(input *inputConsensusTimeout)
224225 return cl .varConsInsts .ConsTimeout (input .logIndex , cl .varLogIndex .ConsensusStarted )
225226}
226227
227- func (cl * cmtLogImpl ) handleInputCanPropose () {
228+ func (cl * cmtLogImpl ) handleInputCanPropose () gpa.OutMessages {
229+ if cl .first && cl .output != nil && len (cl .output ) > 0 {
230+ // This is a workaround for sending initial NextLI messages on boot.
231+ cl .first = false
232+ msgs := gpa .NoMessages ()
233+ for li := range cl .output {
234+ cl .log .Debugf ("Sending initial NextLI messages for LI=%v" , li )
235+ msgs .AddAll (cl .varLogIndex .ConsensusStarted (li ))
236+ }
237+ return msgs
238+ }
228239 // TODO: Is it still needed?
240+ return nil
229241}
230242
231243func (cl * cmtLogImpl ) handleInputSuspend () {
0 commit comments