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

Fix swarm transient connections logic #241

Merged
merged 1 commit into from
Feb 19, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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