Skip to content

Commit

Permalink
Add msp and gossip to linter checks
Browse files Browse the repository at this point in the history
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 <chrisfer@us.ibm.com>
  • Loading branch information
christo4ferris committed Jan 20, 2017
1 parent 051229a commit 7c45438
Show file tree
Hide file tree
Showing 19 changed files with 21 additions and 24 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ tags
*.log
# bddtest coverage files
bddtests/coverage
# bddtest Dockerfile
bddtests/environments/kafka/Dockerfile
*.cov
# Makefile dummy artifacts
.*-dummy
Expand Down
2 changes: 0 additions & 2 deletions gossip/api/channel.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@ type SecurityAdvisor interface {
// Verify verifies a JoinChannelMessage, returns nil on success,
// and an error on failure
Verify(JoinChannelMessage) error


}

// ChannelNotifier is implemented by the gossip component and is used for the peer
Expand Down
1 change: 0 additions & 1 deletion gossip/comm/comm_impl.go
Original file line number Diff line number Diff line change
Expand Up @@ -544,7 +544,6 @@ func createGRPCLayer(port int) (*grpc.Server, net.Listener, grpc.DialOption, []b
var serverOpts []grpc.ServerOption
var dialOpts grpc.DialOption


keyFileName := fmt.Sprintf("key.%d.pem", rand.Int63())
certFileName := fmt.Sprintf("cert.%d.pem", rand.Int63())

Expand Down
6 changes: 3 additions & 3 deletions gossip/comm/comm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -426,19 +426,19 @@ func TestReConnections(t *testing.T) {

// comm1 connects to comm2
comm1.Send(createGossipMsg(), remotePeer(3612))
waitForMessages(t, out2 , 1, "Comm2 didn't receive a message from comm1 in a timely manner")
waitForMessages(t, out2, 1, "Comm2 didn't receive a message from comm1 in a timely manner")
time.Sleep(time.Second)
// comm2 sends to comm1
comm2.Send(createGossipMsg(), remotePeer(3611))
waitForMessages(t, out1 , 1, "Comm1 didn't receive a message from comm2 in a timely manner")
waitForMessages(t, out1, 1, "Comm1 didn't receive a message from comm2 in a timely manner")

comm1.Stop()
comm1, _ = newCommInstance(3611, naiveSec)
time.Sleep(time.Second)
out1 = make(chan uint64, 1)
go reader(out1, comm1.Accept(acceptAll))
comm2.Send(createGossipMsg(), remotePeer(3611))
waitForMessages(t, out1 , 1, "Comm1 didn't receive a message from comm2 in a timely manner")
waitForMessages(t, out1, 1, "Comm1 didn't receive a message from comm2 in a timely manner")
}

func TestProbe(t *testing.T) {
Expand Down
1 change: 0 additions & 1 deletion gossip/comm/mock/mock_comm.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,4 +186,3 @@ func (mock *commMock) Stop() {
func (mock *commMock) BlackListPKIid(PKIid common.PKIidType) {
// NOOP
}

2 changes: 1 addition & 1 deletion gossip/discovery/discovery.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ limitations under the License.
package discovery

import (
"github.com/hyperledger/fabric/gossip/proto"
"github.com/hyperledger/fabric/gossip/common"
"github.com/hyperledger/fabric/gossip/proto"
)

// CryptoService is an interface that the discovery expects to be implemented and passed on creation
Expand Down
3 changes: 0 additions & 3 deletions gossip/election/election.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ var (
// only 1 leader should be left eventually
// - Peers communicate by gossiping leadership proposal or declaration messages


// The Algorithm, in pseudo code:
//
//
Expand Down Expand Up @@ -86,8 +85,6 @@ var (
// than yourself was received, return.
// Else, declare yourself a leader



// LeaderElectionAdapter is used by the leader election module
// to send and receive messages and to get membership information
type LeaderElectionAdapter interface {
Expand Down
2 changes: 1 addition & 1 deletion gossip/filter/filter.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func CombineRoutingFilters(filters ...RoutingFilter) RoutingFilter {
func SelectPeers(k int, peerPool []discovery.NetworkMember, filters ...RoutingFilter) []*comm.RemotePeer {
var filteredPeers []*comm.RemotePeer
for _, peer := range peerPool {
if CombineRoutingFilters(filters ...)(peer) {
if CombineRoutingFilters(filters...)(peer) {
filteredPeers = append(filteredPeers, &comm.RemotePeer{PKIID: peer.PKIid, Endpoint: peer.Endpoint})
}
}
Expand Down
2 changes: 1 addition & 1 deletion gossip/gossip/certstore.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ func (cs *certStore) handleMessage(msg comm.ReceivedMessage) {
func (cs *certStore) validateIdentityMsg(msg *proto.GossipMessage) error {
idMsg := msg.GetPeerIdentity()
if idMsg == nil {
return fmt.Errorf("Identity empty:", msg)
return fmt.Errorf("Identity empty: %+v", msg)
}
pkiID := idMsg.PkiID
cert := idMsg.Cert
Expand Down
2 changes: 1 addition & 1 deletion gossip/gossip/channel/channel.go
Original file line number Diff line number Diff line change
Expand Up @@ -538,4 +538,4 @@ func (gc *gossipChannel) UpdateStateInfo(msg *proto.GossipMessage) {
// NewStateInfoMessageStore returns a MessageStore
func NewStateInfoMessageStore() msgstore.MessageStore {
return msgstore.NewMessageStore(proto.NewGossipMessageComparator(0), func(m interface{}) {})
}
}
1 change: 1 addition & 0 deletions gossip/gossip/gossip.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"time"

"crypto/tls"

"github.com/hyperledger/fabric/gossip/api"
"github.com/hyperledger/fabric/gossip/comm"
"github.com/hyperledger/fabric/gossip/common"
Expand Down
4 changes: 2 additions & 2 deletions gossip/gossip/gossip_impl.go
Original file line number Diff line number Diff line change
Expand Up @@ -826,13 +826,13 @@ func (g *gossipServiceImpl) createStateInfoMsg(metadata []byte, chainID common.C

b, err := prot.Marshal(stateInfMsg)
if err != nil {
g.logger.Error("Failed marshalling StateInfo message:", err)
g.logger.Error("Failed marshalling StateInfo message: ", err)
return nil, err
}

sig, err := g.mcs.Sign(b)
if err != nil {
g.logger.Errorf("Failed signing StateInfo message:", err)
g.logger.Error("Failed signing StateInfo message: ", err)
return nil, err
}

Expand Down
4 changes: 2 additions & 2 deletions gossip/gossip/gossip_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -766,7 +766,7 @@ var testingg = func(g goroutine) bool {
return strings.Index(g.stack[len(g.stack)-1], "testing.go") != -1
}

func anyOfPredicates(predicates ... goroutinePredicate) goroutinePredicate {
func anyOfPredicates(predicates ...goroutinePredicate) goroutinePredicate {
return func(g goroutine) bool {
for _, pred := range predicates {
if pred(g) {
Expand All @@ -778,7 +778,7 @@ func anyOfPredicates(predicates ... goroutinePredicate) goroutinePredicate {
}

func shouldNotBeRunningAtEnd(gr goroutine) bool {
return ! anyOfPredicates(runTests, goExit, testingg, waitForTestCompl, gossipTest, clientConn, connectionLeak)(gr)
return !anyOfPredicates(runTests, goExit, testingg, waitForTestCompl, gossipTest, clientConn, connectionLeak)(gr)
}

func ensureGoroutineExit(t *testing.T) {
Expand Down
3 changes: 1 addition & 2 deletions gossip/integration/integration.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@ func (cs *naiveCryptoService) Verify(vkID api.PeerIdentityType, signature, messa
}

type orgCryptoService struct {

}

// OrgByPeerIdentity returns the OrgIdentityType
Expand All @@ -114,4 +113,4 @@ func (*orgCryptoService) OrgByPeerIdentity(identity api.PeerIdentityType) api.Or
// and an error on failure
func (*orgCryptoService) Verify(joinChanMsg api.JoinChannelMessage) error {
return nil
}
}
1 change: 1 addition & 0 deletions gossip/proto/extensions.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"bytes"

"fmt"

"github.com/hyperledger/fabric/gossip/common"
"github.com/hyperledger/fabric/gossip/util"
)
Expand Down
2 changes: 1 addition & 1 deletion gossip/state/metastate.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ func (n *NodeMetastate) Update(height uint64) {

// FromBytes - encode from byte array into meta data structure
func FromBytes(buf []byte) (*NodeMetastate, error) {
state := NodeMetastate{}
state := NodeMetastate{}
reader := bytes.NewReader(buf)
// As bytes are written in the big endian to keep supporting
// cross platforming and for consistency reasons read also
Expand Down
3 changes: 2 additions & 1 deletion gossip/state/metastate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package state

import (
"testing"

"github.com/docker/docker/pkg/testutil/assert"
)

Expand Down Expand Up @@ -71,4 +72,4 @@ func TestNodeMetastate_FromBytes(t *testing.T) {
updatedState, err := FromBytes(bytes)
assert.NilError(t, err)
assert.Equal(t, updatedState.Height(), uint64(17))
}
}
2 changes: 1 addition & 1 deletion gossip/util/misc.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,4 +130,4 @@ func PrintStackTrace() {
buf := make([]byte, 1<<16)
runtime.Stack(buf, true)
fmt.Printf("%s", buf)
}
}
2 changes: 1 addition & 1 deletion scripts/golinter.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

set -e

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

for i in "${arr[@]}"
do
Expand Down

0 comments on commit 7c45438

Please sign in to comment.