Skip to content

Commit c198a72

Browse files
author
Luis Sanchez
committed
[FAB-1796] cleanup linter errors
modified: gossip/service/channel.go modified: gossip/service/channel_test.go modified: gossip/service/gossip_service.go Change-Id: Ie645641d99a40de662bc24f02609dff41b589f5c Signed-off-by: Luis Sanchez <[email protected]>
1 parent f78b4b8 commit c198a72

File tree

3 files changed

+16
-19
lines changed

3 files changed

+16
-19
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+
}

gossip/service/gossip_service.go

+7-6
Original file line numberDiff line numberDiff line change
@@ -93,16 +93,17 @@ func (g *gossipServiceImpl) JoinChannel(commiter committer.Committer, block *com
9393
g.lock.Lock()
9494
defer g.lock.Unlock()
9595

96-
if chainID, err := utils.GetChainIDFromBlock(block); err != nil {
96+
chainID, err := utils.GetChainIDFromBlock(block)
97+
if err != nil {
9798
return err
98-
} else {
99-
// Initialize new state provider for given committer
100-
logger.Debug("Creating state provider for chainID", chainID)
101-
g.JoinChan(joinChannelMessage, gossipCommon.ChainID(chainID))
102-
g.chains[chainID] = state.NewGossipStateProvider(chainID, g, commiter)
10399
}
104100

101+
// Initialize new state provider for given committer
102+
logger.Debug("Creating state provider for chainID", chainID)
103+
g.JoinChan(joinChannelMessage, gossipCommon.ChainID(chainID))
104+
g.chains[chainID] = state.NewGossipStateProvider(chainID, g, commiter)
105105
return nil
106+
106107
}
107108

108109
// GetBlock returns block for given chain

0 commit comments

Comments
 (0)