Beispiel #1
0
func (l *Peer) ReceiveMessage(c net.Conn) net.MessageSigning {
	app, err := c.Receive()
	if err != nil {
		dbg.Fatal(l.String(), "could not receive message from", c.PeerName())

	}
	if app.MsgType != net.MessageSigningType {
		dbg.Fatal(l.String(), "MS error: received", app.MsgType.String(), "from", c.PeerName())
	}
	return app.Msg.(net.MessageSigning)
}
Beispiel #2
0
func (l *Peer) ReceiveListBasicSignature(c net.Conn) net.ListBasicSignature {
	app, err := c.Receive()
	if err != nil {
		dbg.Fatal(l.String(), "could not receive listbasicsig from", c.PeerName())
	}

	if app.MsgType != net.ListBasicSignatureType {
		dbg.Fatal(l.String(), "LBS error: received", app.MsgType.String(), "from", c.PeerName())
	}
	return app.Msg.(net.ListBasicSignature)

}
Beispiel #3
0
// Wait for the leader to receive the generated signatures from the servers
func (l *Peer) ReceiveBasicSignature(c net.Conn) *net.BasicSignature {

	appMsg, err := c.Receive()
	if err != nil {
		dbg.Fatal(l.String(), "error decoding message from", c.PeerName())
	}
	if appMsg.MsgType != net.BasicSignatureType {
		dbg.Fatal(l.String(), "Received an unknown type:", appMsg.MsgType.String())
	}
	bs := appMsg.Msg.(net.BasicSignature)
	return &bs
}
Beispiel #4
0
// Will send the message to be signed to everyone
func (l *Peer) SendMessage(msg []byte, c net.Conn) {
	if len(msg) > msgMaxLenght {
		dbg.Fatal("Tried to send a too big message to sign. Abort")
	}
	ms := new(net.MessageSigning)
	ms.Length = len(msg)
	ms.Msg = msg
	err := c.Send(*ms)
	if err != nil {
		dbg.Fatal("Could not send message to", c.PeerName())
	}
}