-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
static check fixes #1076
static check fixes #1076
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
package relay | ||
|
||
import ( | ||
logging "github.com/ipfs/go-log" | ||
logging "github.com/ipfs/go-log/v2" | ||
) | ||
|
||
var log = logging.Logger("autorelay") |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ import ( | |
"context" | ||
"time" | ||
|
||
"github.com/libp2p/go-libp2p-discovery" | ||
"github.com/libp2p/go-libp2p-core/discovery" | ||
|
||
ma "github.com/multiformats/go-multiaddr" | ||
) | ||
|
@@ -20,7 +20,31 @@ func Advertise(ctx context.Context, advertise discovery.Advertiser) { | |
go func() { | ||
select { | ||
case <-time.After(AdvertiseBootDelay): | ||
discovery.Advertise(ctx, advertise, RelayRendezvous, discovery.TTL(AdvertiseTTL)) | ||
go func() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. There was a problem hiding this comment. Choose a reason for hiding this commentThe 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? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah... I see. |
||
for { | ||
ttl, err := advertise.Advertise(ctx, RelayRendezvous, discovery.TTL(AdvertiseTTL)) | ||
if err != nil { | ||
log.Debugf("Error advertising %s: %s", RelayRendezvous, err.Error()) | ||
if ctx.Err() != nil { | ||
return | ||
} | ||
|
||
select { | ||
case <-time.After(2 * time.Minute): | ||
continue | ||
case <-ctx.Done(): | ||
return | ||
} | ||
} | ||
|
||
wait := 7 * ttl / 8 | ||
select { | ||
case <-time.After(wait): | ||
case <-ctx.Done(): | ||
return | ||
} | ||
} | ||
}() | ||
case <-ctx.Done(): | ||
} | ||
}() | ||
|
There was a problem hiding this comment.
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.