Skip to content
Snippets Groups Projects

Channels impl

Merged Benjamin Wenger requested to merge channelsImpl into project/Channels
Compare and Show latest version
6 files
+ 83
77
Compare changes
  • Side-by-side
  • Inline
Files
6
+ 12
12
@@ -10,8 +10,8 @@ import (
"gitlab.com/xx_network/primitives/id"
)
// the adminListener adheres to the broadcast listener interface and is used
// when admin messages are received on the channel
// adminListener adheres to the broadcast listener interface and is used when
// admin messages are received on the channel.
type adminListener struct {
chID *id.ID
trigger triggerAdminEventFunc
@@ -20,28 +20,28 @@ type adminListener struct {
func (al *adminListener) Listen(payload []byte,
receptionID receptionID.EphemeralIdentity, round rounds.Round) {
//Remove the padding
// Remove the padding
payloadUnpadded, err := broadcast.DecodeSizedBroadcast(payload)
if err != nil {
jww.WARN.Printf("Failed to strip the padding on User Message "+
"on channel %s", al.chID)
jww.WARN.Printf(
"Failed to strip the padding on User Message on channel %s", al.chID)
return
}
//get the message ID
// Get the message ID
msgID := channel.MakeMessageID(payloadUnpadded)
//Decode the message as a channel message
// Decode the message as a channel message
cm := &ChannelMessage{}
if err = proto.Unmarshal(payloadUnpadded, cm); err != nil {
jww.WARN.Printf("Failed to unmarshal Channel Message from Admin"+
" on channel %s", al.chID)
jww.WARN.Printf("Failed to unmarshal Channel Message from Admin on "+
"channel %s", al.chID)
return
}
/*CRYPTOGRAPHICALLY RELEVANT CHECKS*/
/* CRYPTOGRAPHICALLY RELEVANT CHECKS */
// check the round to ensure the message is not a replay
// Check the round to ensure that the message is not a replay
if id.Round(cm.RoundID) != round.ID {
jww.WARN.Printf("The round message %s send on %s referenced "+
"(%d) was not the same as the round the message was found on (%d)",
@@ -49,7 +49,7 @@ func (al *adminListener) Listen(payload []byte,
return
}
//Submit the message to the event model for listening
// Submit the message to the event model for listening
al.trigger(al.chID, cm, msgID, receptionID, round)
return
Loading