From a089b5b9f4b5efab46f183c41a700a2625753f4c Mon Sep 17 00:00:00 2001 From: aarshkshah1992 Date: Fri, 19 Feb 2021 17:27:21 +0530 Subject: [PATCH] fix swarm transient conn --- swarm.go | 6 ------ swarm_conn.go | 6 ++++++ 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/swarm.go b/swarm.go index 68f7603f..25f45901 100644 --- a/swarm.go +++ b/swarm.go @@ -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() { diff --git a/swarm_conn.go b/swarm_conn.go index c6af3da9..74c0b522 100644 --- a/swarm_conn.go +++ b/swarm_conn.go @@ -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 {