mirror of https://github.com/status-im/go-waku.git
fix: reduce timeout and increase minimum backoff time
This commit is contained in:
parent
6d9018cb11
commit
55a7d7b332
|
@ -202,9 +202,6 @@ func (c *PeerConnectionStrategy) publishWork(ctx context.Context, p peer.AddrInf
|
|||
case c.dialCh <- p:
|
||||
case <-ctx.Done():
|
||||
return
|
||||
case <-time.After(1 * time.Second):
|
||||
// This timeout is to not lock the goroutine
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -261,6 +258,10 @@ func (c *PeerConnectionStrategy) dialPeers(ctx context.Context) {
|
|||
continue
|
||||
}
|
||||
|
||||
if c.host.Network().Connectedness(pi.ID) == network.Connected {
|
||||
continue
|
||||
}
|
||||
|
||||
c.mux.Lock()
|
||||
val, ok := c.cache.Get(pi.ID)
|
||||
var cachedPeer *connCacheData
|
||||
|
@ -280,10 +281,6 @@ func (c *PeerConnectionStrategy) dialPeers(ctx context.Context) {
|
|||
}
|
||||
c.mux.Unlock()
|
||||
|
||||
if c.host.Network().Connectedness(pi.ID) == network.Connected {
|
||||
continue
|
||||
}
|
||||
|
||||
dialCtx, dialCtxCancel := context.WithTimeout(c.workerCtx, c.dialTimeout)
|
||||
err := c.host.Connect(dialCtx, pi)
|
||||
if err != nil && !errors.Is(err, context.Canceled) {
|
||||
|
|
|
@ -244,9 +244,9 @@ func New(opts ...WakuNodeOption) (*WakuNode, error) {
|
|||
// Setup peer connection strategy
|
||||
cacheSize := 600
|
||||
rngSrc := rand.NewSource(rand.Int63())
|
||||
minBackoff, maxBackoff := time.Second*30, time.Hour
|
||||
minBackoff, maxBackoff := time.Minute, time.Hour
|
||||
bkf := backoff.NewExponentialBackoff(minBackoff, maxBackoff, backoff.FullJitter, time.Second, 5.0, 0, rand.New(rngSrc))
|
||||
w.peerConnector, err = v2.NewPeerConnectionStrategy(cacheSize, w.opts.discoveryMinPeers, network.DialPeerTimeout, bkf, w.log)
|
||||
w.peerConnector, err = v2.NewPeerConnectionStrategy(cacheSize, w.opts.discoveryMinPeers, 20*time.Second, bkf, w.log)
|
||||
if err != nil {
|
||||
w.log.Error("creating peer connection strategy", zap.Error(err))
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue