dial timeout

This commit is contained in:
Sergey Cherepanov 2023-02-17 00:19:05 +03:00
parent 38a74fd195
commit 5b93739487
No known key found for this signature in database
GPG Key ID: 87F8EDE8FBDF637C

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()