Skip to content

Commit

Permalink
Moved setting unmarshaller for signing done message to separate function
Browse files Browse the repository at this point in the history
  • Loading branch information
tomaszslabon committed Aug 21, 2023
1 parent 6c8ec3a commit 9f63184
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
2 changes: 2 additions & 0 deletions pkg/protocol/announcer/announcer.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ type Announcer struct {
membershipValidator *group.MembershipValidator
}

// RegisterUnmarshaller initializes the given broadcast channel to be able to
// handle announcement messages by registering the required unmarshaller.
func RegisterUnmarshaller(channel net.BroadcastChannel) {
channel.SetUnmarshaler(func() net.TaggedUnmarshaler {
return &announcementMessage{}
Expand Down
14 changes: 12 additions & 2 deletions pkg/tbtc/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -241,8 +241,7 @@ func (n *node) getSigningExecutor(
return nil, false, fmt.Errorf("failed to get broadcast channel: [%v]", err)
}

signing.RegisterUnmarshallers(broadcastChannel)
announcer.RegisterUnmarshaller(broadcastChannel)
registerSigningUnmarshallers(broadcastChannel)

membershipValidator := group.NewMembershipValidator(
executorLogger,
Expand Down Expand Up @@ -601,3 +600,14 @@ func withCancelOnBlock(

return blockCtx, cancelBlockCtx
}

// registerSigningUnmarshallers initializes the given broadcast channel to be
// able to perform the signing protocol interactions by registering all the
// required protocol unmarshallers.
func registerSigningUnmarshallers(channel net.BroadcastChannel) {
signing.RegisterUnmarshallers(channel)
announcer.RegisterUnmarshaller(channel)
channel.SetUnmarshaler(func() net.TaggedUnmarshaler {
return &signingDoneMessage{}
})
}
4 changes: 0 additions & 4 deletions pkg/tbtc/signing_done.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,6 @@ func newSigningDoneCheck(
broadcastChannel net.BroadcastChannel,
membershipValidator *group.MembershipValidator,
) *signingDoneCheck {
broadcastChannel.SetUnmarshaler(func() net.TaggedUnmarshaler {
return &signingDoneMessage{}
})

return &signingDoneCheck{
groupSize: groupSize,
broadcastChannel: broadcastChannel,
Expand Down

0 comments on commit 9f63184

Please sign in to comment.