Skip to content

Commit 22b97d4

Browse files
committed
fix: resolve mixed value/pointer receivers
- convert all CollatorProtocolMessage methods to pointer receivers - convert all CollationFetchingResponse methods to pointer receivers - convert all CollationProtocol methods to pointer receivers - remove unused receiver variable names Resolves DeepSource issue GO-W1029
1 parent f6218c0 commit 22b97d4

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

dot/parachain/collator-protocol/messages/protocol_messages.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ func (mvdt *CollationProtocol) SetValue(value any) (err error) {
3939
}
4040
}
4141

42-
func (mvdt CollationProtocol) IndexValue() (index uint, value any, err error) {
42+
func (mvdt *CollationProtocol) IndexValue() (index uint, value any, err error) {
4343
switch mvdt.inner.(type) {
4444
case CollatorProtocolMessage:
4545
return 0, mvdt.inner, nil
@@ -48,7 +48,7 @@ func (mvdt CollationProtocol) IndexValue() (index uint, value any, err error) {
4848
return 0, nil, scale.ErrUnsupportedVaryingDataTypeValue
4949
}
5050

51-
func (mvdt CollationProtocol) Value() (value any, err error) {
51+
func (mvdt *CollationProtocol) Value() (value any, err error) {
5252
_, value, err = mvdt.IndexValue()
5353
return
5454
}
@@ -103,7 +103,7 @@ func (mvdt *CollatorProtocolMessage) SetValue(value any) (err error) {
103103
}
104104
}
105105

106-
func (mvdt CollatorProtocolMessage) IndexValue() (index uint, value any, err error) {
106+
func (mvdt *CollatorProtocolMessage) IndexValue() (index uint, value any, err error) {
107107
switch mvdt.inner.(type) {
108108
case Declare:
109109
return 0, mvdt.inner, nil
@@ -121,7 +121,7 @@ func (mvdt CollatorProtocolMessage) IndexValue() (index uint, value any, err err
121121
return 0, nil, scale.ErrUnsupportedVaryingDataTypeValue
122122
}
123123

124-
func (mvdt CollatorProtocolMessage) Value() (value any, err error) {
124+
func (mvdt *CollatorProtocolMessage) Value() (value any, err error) {
125125
_, value, err = mvdt.IndexValue()
126126
return
127127
}
@@ -176,12 +176,12 @@ type CollationSeconded struct {
176176
}
177177

178178
// Type returns CollationMsgType
179-
func (CollationProtocol) Type() network.MessageType {
179+
func (*CollationProtocol) Type() network.MessageType {
180180
return network.CollationMsgType
181181
}
182182

183183
// Hash returns the hash of the CollationProtocolV1
184-
func (cp CollationProtocol) Hash() (common.Hash, error) {
184+
func (cp *CollationProtocol) Hash() (common.Hash, error) {
185185
// scale encode each extrinsic
186186
encMsg, err := cp.Encode()
187187
if err != nil {
@@ -192,7 +192,7 @@ func (cp CollationProtocol) Hash() (common.Hash, error) {
192192
}
193193

194194
// Encode a collator protocol message using scale encode
195-
func (cp CollationProtocol) Encode() ([]byte, error) {
195+
func (cp *CollationProtocol) Encode() ([]byte, error) {
196196
enc, err := scale.Marshal(cp)
197197
if err != nil {
198198
return nil, err

dot/parachain/collator-protocol/validator-side/collation_fetching.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ func (mvdt *CollationFetchingResponse) SetValue(value any) (err error) {
7575
}
7676
}
7777

78-
func (mvdt CollationFetchingResponse) IndexValue() (index uint, value any, err error) {
78+
func (mvdt *CollationFetchingResponse) IndexValue() (index uint, value any, err error) {
7979
switch mvdt.inner.(type) {
8080
case parachaintypes.Collation:
8181
return 0, mvdt.inner, nil
@@ -84,7 +84,7 @@ func (mvdt CollationFetchingResponse) IndexValue() (index uint, value any, err e
8484
return 0, nil, scale.ErrUnsupportedVaryingDataTypeValue
8585
}
8686

87-
func (mvdt CollationFetchingResponse) Value() (value any, err error) {
87+
func (mvdt *CollationFetchingResponse) Value() (value any, err error) {
8888
_, value, err = mvdt.IndexValue()
8989
return
9090
}

0 commit comments

Comments
 (0)