dial timeout

This commit is contained in:
Sergey Cherepanov 2023-02-17 00:19:05 +03:00 committed by Mikhail Iudin
parent 1a588d0a72
commit 3a43f603fb
No known key found for this signature in database
GPG Key ID: FAAAA8BAABDFF1C0

View File

@ -74,6 +74,9 @@ func (d *dialer) SetPeerAddrs(peerId string, addrs []string) {
}
func (d *dialer) Dial(ctx context.Context, peerId string) (p peer.Peer, err error) {
var ctxCancel context.CancelFunc
ctx, ctxCancel = context.WithTimeout(ctx, time.Second*10)
defer ctxCancel()
d.mu.RLock()
defer d.mu.RUnlock()