mirror of
https://github.com/luxfi/threshold.git
synced 2026-10-30 15:15:53 +00:00
- Remove unnecessary trailing newlines - Fix comment formatting - Adjust indentation and spacing - Remove unused nolint directives
27 lines
653 B
Go
27 lines
653 B
Go
package test
|
|
|
|
import (
|
|
"github.com/luxfi/threshold/pkg/party"
|
|
"github.com/luxfi/threshold/pkg/protocol"
|
|
)
|
|
|
|
// HandlerLoop blocks until the handler has finished. The result of the execution is given by Handler.Result().
|
|
func HandlerLoop(id party.ID, h *protocol.Handler, network *Network) {
|
|
for {
|
|
select {
|
|
// outgoing messages
|
|
case msg, ok := <-h.Listen():
|
|
if !ok {
|
|
// the channel was closed, indicating that the protocol is done executing.
|
|
// Don't wait on network.Done(id) as it may not be signaled properly
|
|
return
|
|
}
|
|
go network.Send(msg)
|
|
|
|
// incoming messages
|
|
case msg := <-network.Next(id):
|
|
h.Accept(msg)
|
|
}
|
|
}
|
|
}
|