Skip to content

Commit

Permalink
chore: remove SubProtocol method from Message interface
Browse files Browse the repository at this point in the history
  • Loading branch information
EclesioMeloJunior committed Jul 25, 2022
1 parent 94bf8d9 commit a380a08
Show file tree
Hide file tree
Showing 5 changed files with 0 additions and 52 deletions.
10 changes: 0 additions & 10 deletions dot/network/block_announce.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,6 @@ type BlockAnnounceMessage struct {
BestBlock bool
}

// SubProtocol returns the block-announces sub-protocol
func (*BlockAnnounceMessage) SubProtocol() string {
return blockAnnounceID
}

// Type returns BlockAnnounceMsgType
func (*BlockAnnounceMessage) Type() byte {
return BlockAnnounceMsgType
Expand Down Expand Up @@ -114,11 +109,6 @@ type BlockAnnounceHandshake struct {
GenesisHash common.Hash
}

// SubProtocol returns the block-announces sub-protocol
func (*BlockAnnounceHandshake) SubProtocol() string {
return blockAnnounceID
}

// String formats a BlockAnnounceHandshake as a string
func (hs *BlockAnnounceHandshake) String() string {
return fmt.Sprintf("BlockAnnounceHandshake Roles=%d BestBlockNumber=%d BestBlockHash=%s GenesisHash=%s",
Expand Down
10 changes: 0 additions & 10 deletions dot/network/light.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,11 +125,6 @@ func newRequest() *request {
}
}

// SubProtocol returns the light sub-protocol
func (l *LightRequest) SubProtocol() string {
return lightID
}

// Encode encodes a LightRequest message using SCALE and appends the type byte to the start
func (l *LightRequest) Encode() ([]byte, error) {
req := request{
Expand Down Expand Up @@ -206,11 +201,6 @@ func newResponse() *response {
}
}

// SubProtocol returns the light sub-protocol
func (l *LightResponse) SubProtocol() string {
return lightID
}

// Encode encodes a LightResponse message using SCALE and appends the type byte to the start
func (l *LightResponse) Encode() ([]byte, error) {
resp := response{
Expand Down
16 changes: 0 additions & 16 deletions dot/network/message.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ const (

// Message must be implemented by all network messages
type Message interface {
SubProtocol() string
Encode() ([]byte, error)
Decode([]byte) error
String() string
Expand Down Expand Up @@ -82,11 +81,6 @@ type BlockRequestMessage struct {
Max *uint32
}

// SubProtocol returns the sync sub-protocol
func (bm *BlockRequestMessage) SubProtocol() string {
return syncID
}

// String formats a BlockRequestMessage as a string
func (bm *BlockRequestMessage) String() string {
hash := common.Hash{}
Expand Down Expand Up @@ -207,11 +201,6 @@ type BlockResponseMessage struct {
BlockData []*types.BlockData
}

// SubProtocol returns the sync sub-protocol
func (bm *BlockResponseMessage) SubProtocol() string {
return syncID
}

// String formats a BlockResponseMessage as a string
func (bm *BlockResponseMessage) String() string {
if bm == nil {
Expand Down Expand Up @@ -362,11 +351,6 @@ type ConsensusMessage struct {
Data []byte
}

// SubProtocol returns the empty, since consensus message sub-protocol is determined by the package using it
func (cm *ConsensusMessage) SubProtocol() string {
return ""
}

// Type returns ConsensusMsgType
func (cm *ConsensusMessage) Type() byte {
return ConsensusMsgType
Expand Down
10 changes: 0 additions & 10 deletions dot/network/transaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,6 @@ type TransactionMessage struct {
Extrinsics []types.Extrinsic
}

// SubProtocol returns the transactions sub-protocol
func (*TransactionMessage) SubProtocol() string {
return transactionsID
}

// Type returns TransactionMsgType
func (*TransactionMessage) Type() byte {
return TransactionMsgType
Expand Down Expand Up @@ -69,11 +64,6 @@ func (*TransactionMessage) IsHandshake() bool {

type transactionHandshake struct{}

// SubProtocol returns the transactions sub-protocol
func (*transactionHandshake) SubProtocol() string {
return transactionsID
}

// String formats a transactionHandshake as a string
func (*transactionHandshake) String() string {
return "transactionHandshake"
Expand Down
6 changes: 0 additions & 6 deletions lib/grandpa/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,6 @@ type GrandpaHandshake struct { //nolint:revive
Roles byte
}

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

// String formats a BlockAnnounceHandshake as a string
func (hs *GrandpaHandshake) String() string {
return fmt.Sprintf("GrandpaHandshake Roles=%d", hs.Roles)
Expand Down

0 comments on commit a380a08

Please sign in to comment.