log dial error

This commit is contained in:
Sergey Cherepanov 2023-04-17 16:08:19 +02:00 committed by Mikhail Iudin
parent d819f7773e
commit 122df895d1
No known key found for this signature in database
GPG Key ID: FAAAA8BAABDFF1C0

View File

@ -6,6 +6,7 @@ import (
"github.com/anytypeio/any-sync/app/ocache" "github.com/anytypeio/any-sync/app/ocache"
"github.com/anytypeio/any-sync/net/dialer" "github.com/anytypeio/any-sync/net/dialer"
"github.com/anytypeio/any-sync/net/peer" "github.com/anytypeio/any-sync/net/peer"
"go.uber.org/zap"
"math/rand" "math/rand"
) )
@ -78,6 +79,8 @@ func (p *pool) GetOneOf(ctx context.Context, peerIds []string) (peer.Peer, error
for _, peerId := range peerIds { for _, peerId := range peerIds {
if v, err := p.cache.Get(ctx, peerId); err == nil { if v, err := p.cache.Get(ctx, peerId); err == nil {
return v.(peer.Peer), nil return v.(peer.Peer), nil
} else {
log.Debug("unable to connect", zap.String("peerId", peerId), zap.Error(err))
} }
} }
return nil, ErrUnableToConnect return nil, ErrUnableToConnect
@ -92,6 +95,8 @@ func (p *pool) DialOneOf(ctx context.Context, peerIds []string) (peer.Peer, erro
for _, peerId := range peerIds { for _, peerId := range peerIds {
if v, err := p.dialer.Dial(ctx, peerId); err == nil { if v, err := p.dialer.Dial(ctx, peerId); err == nil {
return v.(peer.Peer), nil return v.(peer.Peer), nil
} else {
log.Debug("unable to connect", zap.String("peerId", peerId), zap.Error(err))
} }
} }
return nil, ErrUnableToConnect return nil, ErrUnableToConnect