Skip to content

Conversation

@coryschwartz
Copy link
Contributor

various fixes for staticcheck

For context: protocol/.github#41

defer cancel()
return discovery.FindPeers(ctx, ar.discover, RelayRendezvous, discovery.Limit(1000))
var ret []peer.AddrInfo
ch, err := ar.discover.FindPeers(ctx, RelayRendezvous, discovery.Limit(1000))
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be equivilent to the FindPeers util function in go-libp2p-discovery, to convert the channel into a slice.

select {
case <-time.After(AdvertiseBootDelay):
discovery.Advertise(ctx, advertise, RelayRendezvous, discovery.TTL(AdvertiseTTL))
go func() {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is brought in from go-libp2p-discovery.

If it's better to use the Util Functions from there I can swtich back to using them.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, those functions exist so we don't need to duplicate this code. What was the motivation for this change?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah... I see.

// ok give the response to our handler.
if err = msmux.SelectProtoOrFail(ID, s); err != nil {
log.Event(context.TODO(), "IdentifyOpenFailed", c.RemotePeer(), logging.Metadata{"error": err})
// log.Event(context.TODO(), "IdentifyOpenFailed", c.RemotePeer(), logging.Metadata{"error": err})
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a metric that should be emitted here in leiu of depreciated go-log Events?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a structured log message.

lm["wantedPeer"] = func() interface{} { return wanted.Pretty() }
lm["gotPeer"] = func() interface{} { return got.Pretty() }
log.Event(ctx, "routingError", lm)
// log.Event(ctx, "routingError", lm)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this code commented?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This entire function should be deleted and replaced with a call to log.Errorw.

Side note: please (almost) never comment out code unless you're actively debugging.

}
return p
}
// Unused code:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we delete this?

select {
case <-time.After(AdvertiseBootDelay):
discovery.Advertise(ctx, advertise, RelayRendezvous, discovery.TTL(AdvertiseTTL))
go func() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, those functions exist so we don't need to duplicate this code. What was the motivation for this change?

lm["wantedPeer"] = func() interface{} { return wanted.Pretty() }
lm["gotPeer"] = func() interface{} { return got.Pretty() }
log.Event(ctx, "routingError", lm)
// log.Event(ctx, "routingError", lm)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This entire function should be deleted and replaced with a call to log.Errorw.

Side note: please (almost) never comment out code unless you're actively debugging.

@Stebalien Stebalien force-pushed the feat/fix-staticcheck branch from fc3ffcc to 80ee4cd Compare April 29, 2021 21:08
@Stebalien Stebalien force-pushed the feat/fix-staticcheck branch from 80ee4cd to 1f5f748 Compare April 29, 2021 21:13
@Stebalien Stebalien force-pushed the feat/fix-staticcheck branch from 1f5f748 to 2ad02f7 Compare April 29, 2021 21:15
@Stebalien Stebalien merged commit 6391bff into libp2p:master Apr 29, 2021
@aschmahmann aschmahmann mentioned this pull request May 14, 2021
71 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants