Skip to content

Commit

Permalink
fixed bug where closing a channel mid-DKG would cause an infinite loop (
Browse files Browse the repository at this point in the history
  • Loading branch information
CluEleSsUK committed Dec 9, 2022
1 parent 08005f2 commit f864ea9
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions share/dkg/protocol.go
Original file line number Diff line number Diff line change
Expand Up @@ -221,19 +221,29 @@ func (p *Protocol) startFast() {
toFinish()
return
}
case newDeal := <-p.board.IncomingDeal():
case newDeal, ok := <-p.board.IncomingDeal():
if !ok {
p.Error("incoming deal channel closed unexpectedly")
return
}

if err := p.verify(&newDeal); err == nil {
deals.Push(&newDeal)
} else {
p.Error("newDeal", "invalid deal signature:", err)
}

if deals.Len() == oldN {
p.Info("newDeal", "fast moving to response phase", fmt.Sprintf(" got %d deals", oldN))
if !toResp() {
return
}
}
case newResp := <-p.board.IncomingResponse():
case newResp, ok := <-p.board.IncomingResponse():
if !ok {
p.Error("incoming response channel closed unexpectedly")
return
}
if err := p.verify(&newResp); err == nil {
resps.Push(&newResp)
} else {
Expand All @@ -245,7 +255,11 @@ func (p *Protocol) startFast() {
return
}
}
case newJust := <-p.board.IncomingJustification():
case newJust, ok := <-p.board.IncomingJustification():
if !ok {
p.Error("incoming justification channel closed unexpectedly")
return
}
if err := p.verify(&newJust); err == nil {
justifs.Push(&newJust)
} else {
Expand Down

0 comments on commit f864ea9

Please sign in to comment.