Skip to content

Commit

Permalink
not resetting the signatories in the background to prevent race condi…
Browse files Browse the repository at this point in the history
…tion
  • Loading branch information
tok-kkk committed Sep 8, 2021
1 parent 9230a2c commit f4f9b4d
Showing 1 changed file with 8 additions and 13 deletions.
21 changes: 8 additions & 13 deletions replica/replica.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,16 +132,6 @@ func (replica *Replica) Run(ctx context.Context) {
case process.Height:
replica.proc.State = process.DefaultState().WithCurrentHeight(m)
replica.mq.DropMessagesBelowHeight(m)
case []id.Signatory:
procAllowed := map[id.Signatory]bool{}
for _, sig := range m {
procAllowed[sig] = true
}
replica.procsAllowed = procAllowed

scheduler := scheduler.NewRoundRobin(m)
f := len(procAllowed) / 3
replica.proc.ResetF(uint64(f), scheduler)
}
}

Expand Down Expand Up @@ -232,10 +222,15 @@ func (replica *Replica) ResetHeight(ctx context.Context, newHeight process.Heigh
return
}

select {
case <-ctx.Done():
case replica.mch <- signatories:
procAllowed := map[id.Signatory]bool{}
for _, sig := range signatories {
procAllowed[sig] = true
}
replica.procsAllowed = procAllowed

scheduler := scheduler.NewRoundRobin(signatories)
f := len(procAllowed) / 3
replica.proc.ResetF(uint64(f), scheduler)
}

// State returns the current height, round and step of the underlying process.
Expand Down

0 comments on commit f4f9b4d

Please sign in to comment.