Skip to content

Commit fd46d2b

Browse files
authored
Merge pull request #493 from iotaledger/scriptsizefix8
Force initial NextLI messages to be sent eventually.
2 parents 150c6e5 + d0ffefe commit fd46d2b

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

packages/chain/cmt_log/cmt_log.go

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -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

231243
func (cl *cmtLogImpl) handleInputSuspend() {

packages/chain/node.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -738,6 +738,7 @@ func (cni *chainNodeImpl) handleNeedConsensus(ctx context.Context, upd *chainman
738738
cni.consensusInsts.ForEach(func(cmtAddr cryptolib.AddressKey, cmtInsts *shrinkingmap.ShrinkingMap[cmt_log.LogIndex, *consensusInst]) bool {
739739
cmtInsts.ForEach(func(li cmt_log.LogIndex, ci *consensusInst) bool {
740740
if ci.request != nil && !upd.Has(chainmanager.MakeConsensusKey(ci.request.CommitteeAddr, li)) {
741+
ci.Cancel()
741742
cmtInsts.Delete(li)
742743
}
743744
return true

0 commit comments

Comments
 (0)