Skip to content

Commit

Permalink
fixing timeout for signing processes
Browse files Browse the repository at this point in the history
  • Loading branch information
Eduardo committed Nov 27, 2020
1 parent 850df04 commit 7f1d6c2
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion network/zmq/ecdsa_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ func (client *Client) GetECDSARound1MessageList(k int) ([]string, tcecdsa.Round1
}
list := make(tcecdsa.Round1MessageList, 0)
msgIDs := make([]string, 0)
err := doForNTimeout(client.channel, len(client.nodes), client.timeout, client.doMessage(func(msg *message.Message) error {
err := doForNTimeout(client.channel, k, client.timeout, client.doMessage(func(msg *message.Message) error {
keyInitMsg, err := message.DecodeECDSARound1Message(msg.Data[0])
if err != nil {
return fmt.Errorf("corrupt key: %v\n", msg)
Expand Down
2 changes: 1 addition & 1 deletion network/zmq/rsa_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ func (client *Client) GetRSASigShares(k int) (tcrsa.SigShareList, error) {
return nil, fmt.Errorf("cannot get sig shares in a currentMessage state different to getRSASigShare")
}
sigShares := make(tcrsa.SigShareList, 0)
err := doForNTimeout(client.channel, len(client.nodes), client.timeout, client.doMessage(func(msg *message.Message) error {
err := doForNTimeout(client.channel, k, client.timeout, client.doMessage(func(msg *message.Message) error {
sigShare, err := message.DecodeRSASigShare(msg.Data[0])
if err != nil {
return fmt.Errorf("corrupt key: %v\n", msg)
Expand Down
5 changes: 4 additions & 1 deletion network/zmq/utils.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
package zmq

import (
"github.com/niclabs/dtcnode/v3/message"
"log"
"time"

"github.com/niclabs/dtcnode/v3/message"
)

// doForNTimeout listens for N messages from a channel, or until a timeout is raised.
Expand All @@ -14,6 +16,7 @@ func doForNTimeout(ch chan *message.Message, n int, timeout time.Duration, fn fu
select {
case msg := <-ch:
if err := fn(msg); err != nil {
log.Printf("error executing function over received message (this could be because an unexpected or delayed message): %s", err)
continue // Ignores the message
}
acked++
Expand Down

0 comments on commit 7f1d6c2

Please sign in to comment.