Files
tss-lib/test/utils.go
2021-03-01 14:04:21 +08:00

53 lines
1.3 KiB
Go

// Copyright © 2019 Binance
//
// This file is part of Binance. The full Binance copyright notice, including
// terms governing use, modification, and redistribution, is contained in the
// file LICENSE at the root of the source code distribution tree.
package test
import (
"github.com/binance-chain/tss-lib/tss"
)
func SharedPartyUpdater(party tss.Party, msg tss.Message, errCh chan<- *tss.Error) {
// do not send a message from this party back to itself
if party.PartyID() == msg.GetFrom() {
return
}
bz, _, err := msg.WireBytes()
if err != nil {
errCh <- party.WrapError(err)
return
}
pMsg, err := tss.ParseWireMessage(bz, msg.GetFrom(), msg.IsBroadcast())
if err != nil {
errCh <- party.WrapError(err)
return
}
if _, err := party.Update(pMsg); err != nil {
errCh <- err
}
}
func SharedPartyUpdaterWithQueues(party tss.Party, msg tss.Message, errCh chan<- *tss.Error) {
// do not send a message from this party back to itself
if party.PartyID() == msg.GetFrom() {
return
}
bz, _, err := msg.WireBytes()
if err != nil {
errCh <- party.WrapError(err)
return
}
pMsg, err := tss.ParseWireMessage(bz, msg.GetFrom(), msg.IsBroadcast())
if err != nil {
errCh <- party.WrapError(err)
return
}
qParty := party.(tss.QueuingParty)
if _, err := qParty.ValidateAndStoreInQueues(pMsg); err != nil {
errCh <- err
}
}