Skip to content

Commit

Permalink
Merge pull request #327 from yacovm/golintgossip
Browse files Browse the repository at this point in the history
Golint gossip/gossip/
  • Loading branch information
yacovm committed Nov 28, 2019
2 parents c5d4087 + 01d1eb4 commit 4cec60e
Show file tree
Hide file tree
Showing 5 changed files with 74 additions and 69 deletions.
16 changes: 8 additions & 8 deletions gossip/gossip/chanstate.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ type channelState struct {
stopping int32
sync.RWMutex
channels map[string]channel.GossipChannel
g *GossipImpl
g *Node
}

func (cs *channelState) stop() {
Expand Down Expand Up @@ -104,7 +104,7 @@ func (cs *channelState) joinChannel(joinMsg api.JoinChannelMessage, channelID co
defer cs.Unlock()
if gc, exists := cs.channels[string(channelID)]; !exists {
pkiID := cs.g.comm.GetPKIid()
ga := &gossipAdapterImpl{GossipImpl: cs.g, Discovery: cs.g.disc}
ga := &gossipAdapterImpl{Node: cs.g, Discovery: cs.g.disc}
gc := channel.NewGossipChannel(pkiID, cs.g.selfOrg, cs.g.mcs, channelID, ga, joinMsg, metrics, nil)
cs.channels[string(channelID)] = gc
} else {
Expand All @@ -113,7 +113,7 @@ func (cs *channelState) joinChannel(joinMsg api.JoinChannelMessage, channelID co
}

type gossipAdapterImpl struct {
*GossipImpl
*Node
discovery.Discovery
}

Expand Down Expand Up @@ -154,7 +154,7 @@ func (ga *gossipAdapterImpl) Sign(msg *proto.GossipMessage) (*protoext.SignedGos

// Gossip gossips a message
func (ga *gossipAdapterImpl) Gossip(msg *protoext.SignedGossipMessage) {
ga.GossipImpl.emitter.Add(&emittedGossipMessage{
ga.Node.emitter.Add(&emittedGossipMessage{
SignedGossipMessage: msg,
filter: func(_ common.PKIidType) bool {
return true
Expand All @@ -164,25 +164,25 @@ func (ga *gossipAdapterImpl) Gossip(msg *protoext.SignedGossipMessage) {

// Forward sends message to the next hops
func (ga *gossipAdapterImpl) Forward(msg protoext.ReceivedMessage) {
ga.GossipImpl.emitter.Add(&emittedGossipMessage{
ga.Node.emitter.Add(&emittedGossipMessage{
SignedGossipMessage: msg.GetGossipMessage(),
filter: msg.GetConnectionInfo().ID.IsNotSameFilter,
})
}

func (ga *gossipAdapterImpl) Send(msg *protoext.SignedGossipMessage, peers ...*comm.RemotePeer) {
ga.GossipImpl.comm.Send(msg, peers...)
ga.Node.comm.Send(msg, peers...)
}

// ValidateStateInfoMessage returns error if a message isn't valid
// nil otherwise
func (ga *gossipAdapterImpl) ValidateStateInfoMessage(msg *protoext.SignedGossipMessage) error {
return ga.GossipImpl.validateStateInfoMsg(msg)
return ga.Node.validateStateInfoMsg(msg)
}

// GetOrgOfPeer returns the organization identifier of a certain peer
func (ga *gossipAdapterImpl) GetOrgOfPeer(PKIID common.PKIidType) api.OrgIdentityType {
return ga.GossipImpl.getOrgOfPeer(PKIID)
return ga.Node.getOrgOfPeer(PKIID)
}

// GetIdentityByPKIID returns an identity of a peer with a certain
Expand Down
1 change: 1 addition & 0 deletions gossip/gossip/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ type Config struct {
ReconnectInterval time.Duration
}

// GlobalConfig builds a Config from the given endpoint, certificate and bootstrap peers.
func GlobalConfig(endpoint string, certs *common.TLSCertificates, bootPeers ...string) (*Config, error) {
c := &Config{}
err := c.loadConfig(endpoint, certs, bootPeers...)
Expand Down

0 comments on commit 4cec60e

Please sign in to comment.