Skip to content

Commit

Permalink
Merge pull request #105 from renproject/merge/master
Browse files Browse the repository at this point in the history
Merge latest changes from master
  • Loading branch information
ross-pure authored Dec 1, 2021
2 parents b7b72b2 + a07629c commit 0e8e090
Show file tree
Hide file tree
Showing 7 changed files with 542 additions and 55 deletions.
32 changes: 21 additions & 11 deletions mq/mq.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,22 +33,32 @@ func New(opts Options) MessageQueue {
// have heights up to (and including) the given height. The appropriate callback
// will be called for every message that is consumed. All consumed messages will
// be dropped from the MessageQueue.
func (mq *MessageQueue) Consume(h process.Height, propose func(process.Propose), prevote func(process.Prevote), precommit func(process.Precommit)) (n int) {
func (mq *MessageQueue) Consume(h process.Height, propose func(process.Propose), prevote func(process.Prevote), precommit func(process.Precommit), procsAllowed map[id.Signatory]bool) (n int) {
for from, q := range mq.queuesByPid {
for len(q) > 0 {
if q[0] == nil || height(q[0]) > h {
break
}
switch msg := q[0].(type) {
case process.Propose:
propose(msg)
case process.Prevote:
prevote(msg)
case process.Precommit:
precommit(msg)
}
n++
q = q[1:]

func() {
defer func() {
n++
q = q[1:]
}()

if ok := procsAllowed[from]; !ok {
return
}

switch msg := q[0].(type) {
case process.Propose:
propose(msg)
case process.Prevote:
prevote(msg)
case process.Precommit:
precommit(msg)
}
}()
}
mq.queuesByPid[from] = q
}
Expand Down
Loading

0 comments on commit 0e8e090

Please sign in to comment.