Skip to content

Commit

Permalink
basichost: prevent duplicate dials
Browse files Browse the repository at this point in the history
  • Loading branch information
marten-seemann committed Mar 17, 2023
1 parent eeb685f commit ed1eea9
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion p2p/host/basic/basic_host.go
Original file line number Diff line number Diff line change
Expand Up @@ -635,8 +635,13 @@ func (h *BasicHost) NewStream(ctx context.Context, p peer.ID, pids ...protocol.I
}
}

s, err := h.Network().NewStream(ctx, p)
s, err := h.Network().NewStream(network.WithNoDial(ctx, "already dialed"), p)
if err != nil {
// TODO: It would be nicer to get the actual error from the swarm,
// but this will require some more work.
if errors.Is(err, network.ErrNoConn) {
return nil, errors.New("connection failed")
}
return nil, err
}

Expand Down

0 comments on commit ed1eea9

Please sign in to comment.