Skip to content

Commit

Permalink
fix(p2p): set connect timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
Wondertan committed Mar 25, 2024
1 parent bdda26a commit 181faa3
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions p2p/peer_tracker.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,8 @@ func (p *peerTracker) bootstrap(ctx context.Context, trusted []libpeer.ID) error

// connectToPeer attempts to connect to the given peer.
func (p *peerTracker) connectToPeer(ctx context.Context, peer libpeer.ID) {
ctx, cancel := context.WithTimeout(ctx, time.Second*5)
defer cancel()
err := p.host.Connect(ctx, p.host.Peerstore().PeerInfo(peer))
if err != nil {
log.Debugw("failed to connect to peer", "id", peer.String(), "err", err)
Expand Down

0 comments on commit 181faa3

Please sign in to comment.