Skip to content

Commit 7c45438

Browse files
Add msp and gossip to linter checks
Add msp and gossip to linter checks Fixed gossip goimport and go vet errors add Dickerfile to .gitignore Change-Id: I7b88f7ae59be3c4b41edce10d69892949cc59cc3 Signed-off-by: Christopher Ferris <[email protected]>
1 parent 051229a commit 7c45438

19 files changed

+21
-24
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ tags
1818
*.log
1919
# bddtest coverage files
2020
bddtests/coverage
21+
# bddtest Dockerfile
22+
bddtests/environments/kafka/Dockerfile
2123
*.cov
2224
# Makefile dummy artifacts
2325
.*-dummy

gossip/api/channel.go

-2
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,6 @@ type SecurityAdvisor interface {
3232
// Verify verifies a JoinChannelMessage, returns nil on success,
3333
// and an error on failure
3434
Verify(JoinChannelMessage) error
35-
36-
3735
}
3836

3937
// ChannelNotifier is implemented by the gossip component and is used for the peer

gossip/comm/comm_impl.go

-1
Original file line numberDiff line numberDiff line change
@@ -544,7 +544,6 @@ func createGRPCLayer(port int) (*grpc.Server, net.Listener, grpc.DialOption, []b
544544
var serverOpts []grpc.ServerOption
545545
var dialOpts grpc.DialOption
546546

547-
548547
keyFileName := fmt.Sprintf("key.%d.pem", rand.Int63())
549548
certFileName := fmt.Sprintf("cert.%d.pem", rand.Int63())
550549

gossip/comm/comm_test.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -426,19 +426,19 @@ func TestReConnections(t *testing.T) {
426426

427427
// comm1 connects to comm2
428428
comm1.Send(createGossipMsg(), remotePeer(3612))
429-
waitForMessages(t, out2 , 1, "Comm2 didn't receive a message from comm1 in a timely manner")
429+
waitForMessages(t, out2, 1, "Comm2 didn't receive a message from comm1 in a timely manner")
430430
time.Sleep(time.Second)
431431
// comm2 sends to comm1
432432
comm2.Send(createGossipMsg(), remotePeer(3611))
433-
waitForMessages(t, out1 , 1, "Comm1 didn't receive a message from comm2 in a timely manner")
433+
waitForMessages(t, out1, 1, "Comm1 didn't receive a message from comm2 in a timely manner")
434434

435435
comm1.Stop()
436436
comm1, _ = newCommInstance(3611, naiveSec)
437437
time.Sleep(time.Second)
438438
out1 = make(chan uint64, 1)
439439
go reader(out1, comm1.Accept(acceptAll))
440440
comm2.Send(createGossipMsg(), remotePeer(3611))
441-
waitForMessages(t, out1 , 1, "Comm1 didn't receive a message from comm2 in a timely manner")
441+
waitForMessages(t, out1, 1, "Comm1 didn't receive a message from comm2 in a timely manner")
442442
}
443443

444444
func TestProbe(t *testing.T) {

gossip/comm/mock/mock_comm.go

-1
Original file line numberDiff line numberDiff line change
@@ -186,4 +186,3 @@ func (mock *commMock) Stop() {
186186
func (mock *commMock) BlackListPKIid(PKIid common.PKIidType) {
187187
// NOOP
188188
}
189-

gossip/discovery/discovery.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ limitations under the License.
1717
package discovery
1818

1919
import (
20-
"github.com/hyperledger/fabric/gossip/proto"
2120
"github.com/hyperledger/fabric/gossip/common"
21+
"github.com/hyperledger/fabric/gossip/proto"
2222
)
2323

2424
// CryptoService is an interface that the discovery expects to be implemented and passed on creation

gossip/election/election.go

-3
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ var (
4545
// only 1 leader should be left eventually
4646
// - Peers communicate by gossiping leadership proposal or declaration messages
4747

48-
4948
// The Algorithm, in pseudo code:
5049
//
5150
//
@@ -86,8 +85,6 @@ var (
8685
// than yourself was received, return.
8786
// Else, declare yourself a leader
8887

89-
90-
9188
// LeaderElectionAdapter is used by the leader election module
9289
// to send and receive messages and to get membership information
9390
type LeaderElectionAdapter interface {

gossip/filter/filter.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ func CombineRoutingFilters(filters ...RoutingFilter) RoutingFilter {
4343
func SelectPeers(k int, peerPool []discovery.NetworkMember, filters ...RoutingFilter) []*comm.RemotePeer {
4444
var filteredPeers []*comm.RemotePeer
4545
for _, peer := range peerPool {
46-
if CombineRoutingFilters(filters ...)(peer) {
46+
if CombineRoutingFilters(filters...)(peer) {
4747
filteredPeers = append(filteredPeers, &comm.RemotePeer{PKIID: peer.PKIid, Endpoint: peer.Endpoint})
4848
}
4949
}

gossip/gossip/certstore.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ func (cs *certStore) handleMessage(msg comm.ReceivedMessage) {
9999
func (cs *certStore) validateIdentityMsg(msg *proto.GossipMessage) error {
100100
idMsg := msg.GetPeerIdentity()
101101
if idMsg == nil {
102-
return fmt.Errorf("Identity empty:", msg)
102+
return fmt.Errorf("Identity empty: %+v", msg)
103103
}
104104
pkiID := idMsg.PkiID
105105
cert := idMsg.Cert

gossip/gossip/channel/channel.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -538,4 +538,4 @@ func (gc *gossipChannel) UpdateStateInfo(msg *proto.GossipMessage) {
538538
// NewStateInfoMessageStore returns a MessageStore
539539
func NewStateInfoMessageStore() msgstore.MessageStore {
540540
return msgstore.NewMessageStore(proto.NewGossipMessageComparator(0), func(m interface{}) {})
541-
}
541+
}

gossip/gossip/gossip.go

+1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import (
2020
"time"
2121

2222
"crypto/tls"
23+
2324
"github.com/hyperledger/fabric/gossip/api"
2425
"github.com/hyperledger/fabric/gossip/comm"
2526
"github.com/hyperledger/fabric/gossip/common"

gossip/gossip/gossip_impl.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -826,13 +826,13 @@ func (g *gossipServiceImpl) createStateInfoMsg(metadata []byte, chainID common.C
826826

827827
b, err := prot.Marshal(stateInfMsg)
828828
if err != nil {
829-
g.logger.Error("Failed marshalling StateInfo message:", err)
829+
g.logger.Error("Failed marshalling StateInfo message: ", err)
830830
return nil, err
831831
}
832832

833833
sig, err := g.mcs.Sign(b)
834834
if err != nil {
835-
g.logger.Errorf("Failed signing StateInfo message:", err)
835+
g.logger.Error("Failed signing StateInfo message: ", err)
836836
return nil, err
837837
}
838838

gossip/gossip/gossip_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -766,7 +766,7 @@ var testingg = func(g goroutine) bool {
766766
return strings.Index(g.stack[len(g.stack)-1], "testing.go") != -1
767767
}
768768

769-
func anyOfPredicates(predicates ... goroutinePredicate) goroutinePredicate {
769+
func anyOfPredicates(predicates ...goroutinePredicate) goroutinePredicate {
770770
return func(g goroutine) bool {
771771
for _, pred := range predicates {
772772
if pred(g) {
@@ -778,7 +778,7 @@ func anyOfPredicates(predicates ... goroutinePredicate) goroutinePredicate {
778778
}
779779

780780
func shouldNotBeRunningAtEnd(gr goroutine) bool {
781-
return ! anyOfPredicates(runTests, goExit, testingg, waitForTestCompl, gossipTest, clientConn, connectionLeak)(gr)
781+
return !anyOfPredicates(runTests, goExit, testingg, waitForTestCompl, gossipTest, clientConn, connectionLeak)(gr)
782782
}
783783

784784
func ensureGoroutineExit(t *testing.T) {

gossip/integration/integration.go

+1-2
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,6 @@ func (cs *naiveCryptoService) Verify(vkID api.PeerIdentityType, signature, messa
101101
}
102102

103103
type orgCryptoService struct {
104-
105104
}
106105

107106
// OrgByPeerIdentity returns the OrgIdentityType
@@ -114,4 +113,4 @@ func (*orgCryptoService) OrgByPeerIdentity(identity api.PeerIdentityType) api.Or
114113
// and an error on failure
115114
func (*orgCryptoService) Verify(joinChanMsg api.JoinChannelMessage) error {
116115
return nil
117-
}
116+
}

gossip/proto/extensions.go

+1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import (
2020
"bytes"
2121

2222
"fmt"
23+
2324
"github.com/hyperledger/fabric/gossip/common"
2425
"github.com/hyperledger/fabric/gossip/util"
2526
)

gossip/state/metastate.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ func (n *NodeMetastate) Update(height uint64) {
5959

6060
// FromBytes - encode from byte array into meta data structure
6161
func FromBytes(buf []byte) (*NodeMetastate, error) {
62-
state := NodeMetastate{}
62+
state := NodeMetastate{}
6363
reader := bytes.NewReader(buf)
6464
// As bytes are written in the big endian to keep supporting
6565
// cross platforming and for consistency reasons read also

gossip/state/metastate_test.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ package state
1818

1919
import (
2020
"testing"
21+
2122
"github.com/docker/docker/pkg/testutil/assert"
2223
)
2324

@@ -71,4 +72,4 @@ func TestNodeMetastate_FromBytes(t *testing.T) {
7172
updatedState, err := FromBytes(bytes)
7273
assert.NilError(t, err)
7374
assert.Equal(t, updatedState.Height(), uint64(17))
74-
}
75+
}

gossip/util/misc.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -130,4 +130,4 @@ func PrintStackTrace() {
130130
buf := make([]byte, 1<<16)
131131
runtime.Stack(buf, true)
132132
fmt.Printf("%s", buf)
133-
}
133+
}

scripts/golinter.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
set -e
44

5-
declare -a arr=("./core" "./events" "./examples" "./peer" "./protos" "./orderer")
5+
declare -a arr=("./core" "./events" "./examples" "./peer" "./protos" "./orderer" "./msp" "./gossip")
66

77
for i in "${arr[@]}"
88
do

0 commit comments

Comments
 (0)