mirror of
https://github.com/SwingbyProtocol/tss-lib.git
synced 2026-04-23 03:00:36 -04:00
53 lines
1.3 KiB
Go
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
|
|
}
|
|
}
|