Skip to content

Commit 5c171cc

Browse files
author
conghonglei
committed
Fix gossip linter failure
ATT. goimports re-format gossip/service/channle, to make it pass linter check. Change-Id: I1c26f05fdfd5e689941b0fe798c6d07e8fa8b68a Signed-off-by: conghonglei <[email protected]>
1 parent f78b4b8 commit 5c171cc

File tree

2 files changed

+9
-13
lines changed

2 files changed

+9
-13
lines changed

gossip/service/channel.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,16 @@ package service
1919
import (
2020
"fmt"
2121

22+
"github.com/golang/protobuf/proto"
2223
"github.com/hyperledger/fabric/gossip/api"
2324
"github.com/hyperledger/fabric/protos/common"
2425
"github.com/hyperledger/fabric/protos/peer"
25-
"github.com/golang/protobuf/proto"
2626
"github.com/hyperledger/fabric/protos/utils"
2727
)
2828

2929
// unMarshal is used to un-marshall proto-buffer types.
3030
// In tests, I override this variable with a function
31-
var unMarshal func (buf []byte, pb proto.Message) error
31+
var unMarshal func(buf []byte, pb proto.Message) error
3232

3333
func init() {
3434
unMarshal = proto.Unmarshal
@@ -37,7 +37,7 @@ func init() {
3737
// This is an implementation of api.JoinChannelMessage.
3838
// This object is created from a *common.Block
3939
type joinChannelMessage struct {
40-
seqNum uint64
40+
seqNum uint64
4141
anchorPeers []api.AnchorPeer
4242
}
4343

@@ -91,7 +91,7 @@ func parseBlock(block *common.Block) (*peer.AnchorPeers, error) {
9191
found = true
9292
anchorPeerConfig = confItem
9393
}
94-
if ! found {
94+
if !found {
9595
return nil, fmt.Errorf("Didn't find AnchorPeer definition in configuration block")
9696
}
9797
rawAnchorPeersBytes := anchorPeerConfig.Value

gossip/service/channel_test.go

+5-9
Original file line numberDiff line numberDiff line change
@@ -21,18 +21,17 @@ import (
2121
"testing"
2222
"time"
2323

24+
"github.com/golang/protobuf/proto"
25+
"github.com/hyperledger/fabric/common/configtx"
2426
"github.com/hyperledger/fabric/common/genesis"
2527
"github.com/hyperledger/fabric/protos/common"
2628
"github.com/hyperledger/fabric/protos/peer"
27-
"github.com/golang/protobuf/proto"
28-
"github.com/stretchr/testify/assert"
29-
"github.com/hyperledger/fabric/common/configtx"
3029
"github.com/hyperledger/fabric/protos/utils"
30+
"github.com/stretchr/testify/assert"
3131
)
3232

3333
type blockInvalidator func(*common.Block) *common.Block
3434

35-
3635
// unMarshaller is a mock for proto.Unmarshal
3736
// that fails on an Nth attempt
3837
type unMarshaller struct {
@@ -47,7 +46,7 @@ func (um *unMarshaller) unMarshal(buf []byte, pb proto.Message) error {
4746
return proto.Unmarshal(buf, pb)
4847
}
4948

50-
func failUnmarshallAtAttempt(attempts int) func (buf []byte, pb proto.Message) error {
49+
func failUnmarshallAtAttempt(attempts int) func(buf []byte, pb proto.Message) error {
5150
um := &unMarshaller{attemptsLeft: attempts}
5251
return um.unMarshal
5352
}
@@ -104,7 +103,6 @@ func TestInvalidJoinChannelBlock(t *testing.T) {
104103
}
105104
testJoinChannelFails(t, multipleAnchorPeers, nil)
106105

107-
108106
noAnchorPeers := func(_ *common.Block) *common.Block {
109107
anchorPeers := &peer.AnchorPeers{
110108
AnchorPees: []*peer.AnchorPeer{},
@@ -137,7 +135,6 @@ func TestValidJoinChannelBlock(t *testing.T) {
137135
assert.Equal(t, []byte("cert"), []byte(jcm.AnchorPeers()[0].Cert))
138136
}
139137

140-
141138
func testJoinChannelFails(t *testing.T, invalidator blockInvalidator, unMarshallFunc func(buf []byte, pb proto.Message) error) {
142139
if unMarshallFunc != nil {
143140
unMarshal = unMarshallFunc
@@ -155,7 +152,6 @@ func testJoinChannelFails(t *testing.T, invalidator blockInvalidator, unMarshall
155152
unMarshal = proto.Unmarshal
156153
}
157154

158-
159155
func createValidJoinChanMessage(t *testing.T, seqNum int, host string, port int, cert []byte) *common.Block {
160156
anchorPeers := &peer.AnchorPeers{
161157
AnchorPees: []*peer.AnchorPeer{{Cert: cert, Host: host, Port: int32(port)}},
@@ -181,4 +177,4 @@ func createAnchorPeerConfItem(t *testing.T, anchorPeers *peer.AnchorPeers, key s
181177
Type: common.ConfigurationItem_Peer,
182178
Value: serializedAnchorPeers,
183179
}
184-
}
180+
}

0 commit comments

Comments
 (0)