Skip to content
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

cleanup: fix vet and staticcheck failures #435

Merged
merged 3 commits into from
Jul 22, 2021
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
1 change: 1 addition & 0 deletions discovery_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,7 @@ func TestGossipSubDiscoveryAfterBootstrap(t *testing.T) {
}
}

//lint:ignore U1000 used only by skipped tests at present
func waitUntilGossipsubMeshCount(ps *PubSub, topic string, count int) {
done := false
doneCh := make(chan bool, 1)
Expand Down
3 changes: 0 additions & 3 deletions gossip_tracer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,10 @@ func TestBrokenPromises(t *testing.T) {
peerB := peer.ID("B")
peerC := peer.ID("C")

var msgs []*pb.Message
var mids []string
for i := 0; i < 100; i++ {
m := makeTestMessage(i)
m.From = []byte(peerA)
msgs = append(msgs, m)
mid := DefaultMsgIdFn(m)
mids = append(mids, mid)
}
Expand Down Expand Up @@ -97,5 +95,4 @@ func TestNoBrokenPromises(t *testing.T) {
if brokenPromises != nil {
t.Fatal("expected no broken promises")
}

}
12 changes: 5 additions & 7 deletions gossipsub.go
Original file line number Diff line number Diff line change
Expand Up @@ -210,8 +210,8 @@ func NewGossipSub(ctx context.Context, h host.Host, opts ...Option) (*PubSub, er
outbound: make(map[peer.ID]bool),
connect: make(chan connectInfo, params.MaxPendingConnections),
mcache: NewMessageCache(params.HistoryGossip, params.HistoryLength),
protos: GossipSubDefaultProtocols,
feature: GossipSubDefaultFeatures,
protos: GossipSubDefaultProtocols,
feature: GossipSubDefaultFeatures,
tagTracer: newTagTracer(h.ConnManager()),
params: params,
}
Expand Down Expand Up @@ -668,7 +668,7 @@ func (gs *GossipSubRouter) handleIHave(p peer.ID, ctl *pb.ControlMessage) []*pb.

gs.gossipTracer.AddPromise(p, iwantlst)

return []*pb.ControlIWant{&pb.ControlIWant{MessageIDs: iwantlst}}
return []*pb.ControlIWant{{MessageIDs: iwantlst}}
}

func (gs *GossipSubRouter) handleIWant(p peer.ID, ctl *pb.ControlMessage) []*pb.Message {
Expand Down Expand Up @@ -901,7 +901,6 @@ func (gs *GossipSubRouter) pxConnect(peers []*pb.PeerInfo) {
case gs.connect <- ci:
default:
log.Debugf("ignoring peer connection attempt; too many pending connections")
break
}
}
}
Expand Down Expand Up @@ -1078,7 +1077,7 @@ func (gs *GossipSubRouter) Leave(topic string) {
}

func (gs *GossipSubRouter) sendGraft(p peer.ID, topic string) {
graft := []*pb.ControlGraft{&pb.ControlGraft{TopicID: &topic}}
graft := []*pb.ControlGraft{{TopicID: &topic}}
out := rpcWithControl(nil, nil, nil, graft, nil)
gs.sendRPC(p, out)
}
Expand Down Expand Up @@ -1297,7 +1296,7 @@ func (gs *GossipSubRouter) heartbeatTimer() {
}

func (gs *GossipSubRouter) heartbeat() {
defer log.EventBegin(gs.p.ctx, "heartbeat").Done()
defer log.Infow("heartbeat")

gs.heartbeatTicks++

Expand Down Expand Up @@ -1650,7 +1649,6 @@ func (gs *GossipSubRouter) sendGraftPrune(tograft, toprune map[peer.ID][]string,
out := rpcWithControl(nil, nil, nil, nil, prune)
gs.sendRPC(p, out)
}

}

// emitGossip emits IHAVE gossip advertising items in the message cache window
Expand Down
7 changes: 1 addition & 6 deletions gossipsub_connmgr_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,9 @@ func TestGossipsubConnTagMessageDeliveries(t *testing.T) {

// sybil squatters to be connected later
sybilHosts := getNetHosts(t, ctx, nSquatter)
squatters := make([]*sybilSquatter, 0, nSquatter)
for _, h := range sybilHosts {
squatter := &sybilSquatter{h: h}
h.SetStreamHandler(GossipSubID_v10, squatter.handleStream)
squatters = append(squatters, squatter)
}

// connect the honest hosts
Expand All @@ -97,14 +95,11 @@ func TestGossipsubConnTagMessageDeliveries(t *testing.T) {

// subscribe everyone to the topic
topic := "test"
var msgs []*Subscription
for _, ps := range psubs {
subch, err := ps.Subscribe(topic)
_, err := ps.Subscribe(topic)
if err != nil {
t.Fatal(err)
}

msgs = append(msgs, subch)
}

// sleep to allow meshes to form
Expand Down
6 changes: 1 addition & 5 deletions gossipsub_feat_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,7 @@ func TestGossipSubCustomProtocols(t *testing.T) {
customsub := protocol.ID("customsub/1.0.0")
protos := []protocol.ID{customsub, FloodSubID}
features := func(feat GossipSubFeature, proto protocol.ID) bool {
if proto == customsub {
return true
}

return false
return proto == customsub
}

ctx, cancel := context.WithCancel(context.Background())
Expand Down
Loading