Skip to content

Commit

Permalink
feat: update grandpa protocol ID
Browse files Browse the repository at this point in the history
  • Loading branch information
EclesioMeloJunior committed Jul 15, 2022
1 parent 3a471d9 commit 855d1da
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions lib/grandpa/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ package grandpa

import (
"fmt"
"strings"
"time"

"github.com/ChainSafe/gossamer/dot/network"
Expand All @@ -15,10 +16,11 @@ import (
"github.com/libp2p/go-libp2p-core/protocol"
)

const grandpaID1 = "grandpa/1"

var (
grandpaID protocol.ID = "/paritytech/grandpa/1"
messageID = network.ConsensusMsgType
neighbourMessageInterval = time.Minute * 5
messageID = network.ConsensusMsgType
neighbourMessageInterval = time.Minute * 5
)

// Handshake is an alias for network.Handshake
Expand All @@ -38,9 +40,10 @@ type GrandpaHandshake struct { //nolint:revive
Roles byte
}

// TODO: should we remove the SubProtocol mehtod from the `Message` interface?
// SubProtocol returns the grandpa sub-protocol
func (*GrandpaHandshake) SubProtocol() string {
return string(grandpaID)
return ""
}

// String formats a BlockAnnounceHandshake as a string
Expand Down Expand Up @@ -74,8 +77,12 @@ func (*GrandpaHandshake) IsHandshake() bool {
}

func (s *Service) registerProtocol() error {
genesisHash := s.blockState.GenesisHash().String()
genesisHash = strings.TrimPrefix(genesisHash, "0x")
grandpaProtocolID := fmt.Sprintf("/%s/%s", genesisHash, grandpaID1)

return s.network.RegisterNotificationsProtocol(
grandpaID,
protocol.ID(grandpaProtocolID),
messageID,
s.getHandshake,
s.decodeHandshake,
Expand Down

0 comments on commit 855d1da

Please sign in to comment.