Skip to content
This repository has been archived by the owner on May 26, 2022. It is now read-only.

Commit

Permalink
fix swarm transient conn (#241)
Browse files Browse the repository at this point in the history
  • Loading branch information
aarshkshah1992 authored Feb 19, 2021
1 parent f82c425 commit 3563ed1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 0 additions & 6 deletions swarm.go
Original file line number Diff line number Diff line change
Expand Up @@ -360,12 +360,6 @@ func (s *Swarm) NewStream(ctx context.Context, p peer.ID) (network.Stream, error
}
}

if c.Stat().Transient {
if useTransient, _ := network.GetUseTransient(ctx); !useTransient {
return nil, network.ErrTransientConn
}
}

s, err := c.NewStream(ctx)
if err != nil {
if c.conn.IsClosed() {
Expand Down
6 changes: 6 additions & 0 deletions swarm_conn.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,12 @@ func (c *Conn) Stat() network.Stat {

// NewStream returns a new Stream from this connection
func (c *Conn) NewStream(ctx context.Context) (network.Stream, error) {
if c.Stat().Transient {
if useTransient, _ := network.GetUseTransient(ctx); !useTransient {
return nil, network.ErrTransientConn
}
}

ts, err := c.conn.OpenStream(ctx)

if err != nil {
Expand Down

0 comments on commit 3563ed1

Please sign in to comment.