mirror of
https://github.com/luxfi/mpc.git
synced 2026-09-24 00:26:24 +00:00
Increase direct messsage timeout, add mutex lock for party updating
This commit is contained in:
@@ -22,7 +22,7 @@ func NewNatsDirectMessaging(natsConn *nats.Conn) DirectMessaging {
|
||||
}
|
||||
|
||||
func (d *natsDirectMessaging) Send(id string, message []byte) error {
|
||||
_, err := d.natsConn.Request(id, message, 1*time.Second)
|
||||
_, err := d.natsConn.Request(id, message, 3*time.Second)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package mpc
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
"sync"
|
||||
|
||||
"github.com/bnb-chain/tss-lib/ecdsa/keygen"
|
||||
"github.com/bnb-chain/tss-lib/tss"
|
||||
@@ -36,6 +37,7 @@ type Session struct {
|
||||
successQueue messaging.MessageQueue
|
||||
|
||||
topicComposer *TopicComposer
|
||||
mu sync.Mutex
|
||||
}
|
||||
|
||||
func (s *Session) PartyID() *tss.PartyID {
|
||||
@@ -105,6 +107,8 @@ func (s *Session) receiveTssMessage(rawMsg []byte) {
|
||||
isToSelf := len(msg.To) == 1 && ComparePartyIDs(msg.To[0], s.selfPartyID)
|
||||
|
||||
if isBroadcast || isToSelf {
|
||||
s.mu.Lock()
|
||||
defer s.mu.Unlock()
|
||||
ok, err := s.party.UpdateFromBytes(msg.MsgBytes, msg.From, msg.IsBroadcast)
|
||||
if !ok || err != nil {
|
||||
logger.Error("Failed to update party", err, "walletID", s.walletID)
|
||||
|
||||
Reference in New Issue
Block a user