File tree Expand file tree Collapse file tree 1 file changed +25
-2
lines changed
Expand file tree Collapse file tree 1 file changed +25
-2
lines changed Original file line number Diff line number Diff line change 55 "time"
66
77 "github.com/libp2p/go-libp2p-core/discovery"
8- disc "github.com/libp2p/go-libp2p-discovery"
98
109 ma "github.com/multiformats/go-multiaddr"
1110)
@@ -21,7 +20,31 @@ func Advertise(ctx context.Context, advertise discovery.Advertiser) {
2120 go func () {
2221 select {
2322 case <- time .After (AdvertiseBootDelay ):
24- disc .Advertise (ctx , advertise , RelayRendezvous , discovery .TTL (AdvertiseTTL ))
23+ go func () {
24+ for {
25+ ttl , err := advertise .Advertise (ctx , RelayRendezvous , discovery .TTL (AdvertiseTTL ))
26+ if err != nil {
27+ log .Debugf ("Error advertising %s: %s" , RelayRendezvous , err .Error ())
28+ if ctx .Err () != nil {
29+ return
30+ }
31+
32+ select {
33+ case <- time .After (2 * time .Minute ):
34+ continue
35+ case <- ctx .Done ():
36+ return
37+ }
38+ }
39+
40+ wait := 7 * ttl / 8
41+ select {
42+ case <- time .After (wait ):
43+ case <- ctx .Done ():
44+ return
45+ }
46+ }
47+ }()
2548 case <- ctx .Done ():
2649 }
2750 }()
You can’t perform that action at this time.
0 commit comments