add delay in initial relay advertisement to allow the dht time to bootstrap
This commit is contained in:
parent
14fad346b7
commit
31eb77d446
|
@ -26,9 +26,10 @@ import (
|
|||
|
||||
// test specific parameters
|
||||
func init() {
|
||||
autonat.AutoNATIdentifyDelay = 100 * time.Millisecond
|
||||
autonat.AutoNATIdentifyDelay = 500 * time.Millisecond
|
||||
autonat.AutoNATBootDelay = 1 * time.Second
|
||||
relay.BootDelay = 1 * time.Second
|
||||
relay.AdvertiseBootDelay = 1 * time.Millisecond
|
||||
manet.Private4 = []*net.IPNet{}
|
||||
}
|
||||
|
||||
|
|
|
@ -2,6 +2,7 @@ package relay
|
|||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
basic "github.com/libp2p/go-libp2p/p2p/host/basic"
|
||||
|
||||
|
@ -10,6 +11,10 @@ import (
|
|||
ma "github.com/multiformats/go-multiaddr"
|
||||
)
|
||||
|
||||
var (
|
||||
AdvertiseBootDelay = 5 * time.Second
|
||||
)
|
||||
|
||||
// RelayHost is a Host that provides Relay services.
|
||||
type RelayHost struct {
|
||||
*basic.BasicHost
|
||||
|
@ -25,7 +30,10 @@ func NewRelayHost(ctx context.Context, bhost *basic.BasicHost, advertise discove
|
|||
advertise: advertise,
|
||||
}
|
||||
bhost.AddrsFactory = h.hostAddrs
|
||||
discovery.Advertise(ctx, advertise, RelayRendezvous)
|
||||
go func() {
|
||||
time.Sleep(AdvertiseBootDelay)
|
||||
discovery.Advertise(ctx, advertise, RelayRendezvous)
|
||||
}()
|
||||
return h
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue