Skip to content

Golint gossip/gossip/ #327

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 28, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading