Increase direct messsage timeout, add mutex lock for party updating

This commit is contained in:
anhthii
2024-02-04 22:51:40 +07:00
parent 2dd5d1a47a
commit f274504dfe
2 changed files with 5 additions and 1 deletions
+1 -1
View File
@@ -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
}
+4
View File
@@ -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)