Skip to content

Commit

Permalink
address review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
sukunrt committed Sep 14, 2023
1 parent d8f93fc commit 37d9e4e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
9 changes: 5 additions & 4 deletions p2p/net/swarm/swarm.go
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,8 @@ func (s *Swarm) StreamHandler() network.StreamHandler {
}

// NewStream creates a new stream on any available connection to peer, dialing
// if necessary. Use network.WithUseTransient to open a stream over a transient(relayed)
// if necessary.
// Use network.WithUseTransient to open a stream over a transient(relayed)
// connection.
func (s *Swarm) NewStream(ctx context.Context, p peer.ID) (network.Stream, error) {
log.Debugf("[%s] opening stream to peer [%s]", s.local, p)
Expand Down Expand Up @@ -546,9 +547,9 @@ func (s *Swarm) bestConnToPeer(p peer.ID) *Conn {
return best
}

// bestAcceptableConnToPeer returns the best acceptable connection in the ctx passed. If
// network.WithForceDirectDial is used, it'll only returns a direct connection ignoring
// any transient(relayed) connections to the peer.
// bestAcceptableConnToPeer returns the best acceptable connection, considering the passed in ctx.
// If network.WithForceDirectDial is used, it only returns a direct connections, ignoring
// any transient (relayed) connections to the peer.
func (s *Swarm) bestAcceptableConnToPeer(ctx context.Context, p peer.ID) *Conn {
conn := s.bestConnToPeer(p)

Expand Down
1 change: 1 addition & 0 deletions p2p/test/swarm/swarm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ func TestDialPeerTransientConnection(t *testing.T) {
require.NoError(t, err)
require.NotNil(t, conn1)

// Test that repeated calls return the same connection.
conn2, err := h1.Network().DialPeer(context.Background(), h2.ID())
require.NoError(t, err)
require.NotNil(t, conn2)
Expand Down

0 comments on commit 37d9e4e

Please sign in to comment.