From 5e30cdeaacdfdb1394048e6aa9668a4bfe78cb36 Mon Sep 17 00:00:00 2001 From: Hlib Date: Fri, 28 Feb 2020 17:21:51 +0200 Subject: [PATCH] use of mux.ErrReset --- p2p/net/mock/mock_stream.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/p2p/net/mock/mock_stream.go b/p2p/net/mock/mock_stream.go index 2bf8929686..d71e53c115 100644 --- a/p2p/net/mock/mock_stream.go +++ b/p2p/net/mock/mock_stream.go @@ -8,6 +8,7 @@ import ( "sync/atomic" "time" + "github.com/libp2p/go-libp2p-core/mux" "github.com/libp2p/go-libp2p-core/network" protocol "github.com/libp2p/go-libp2p-core/protocol" ) @@ -29,7 +30,6 @@ type stream struct { stat network.Stat } -var ErrReset error = errors.New("stream reset") var ErrClosed error = errors.New("stream closed") type transportObject struct { @@ -98,8 +98,8 @@ func (s *stream) Close() error { func (s *stream) Reset() error { // Cancel any pending reads/writes with an error. - s.write.CloseWithError(ErrReset) - s.read.CloseWithError(ErrReset) + s.write.CloseWithError(mux.ErrReset) + s.read.CloseWithError(mux.ErrReset) select { case s.reset <- struct{}{}: @@ -206,7 +206,7 @@ func (s *stream) transport() { case s.reset <- struct{}{}: default: } - return ErrReset + return mux.ErrReset } if err := drainBuf(); err != nil { return err @@ -226,14 +226,14 @@ func (s *stream) transport() { // Reset takes precedent. select { case <-s.reset: - s.writeErr = ErrReset + s.writeErr = mux.ErrReset return default: } select { case <-s.reset: - s.writeErr = ErrReset + s.writeErr = mux.ErrReset return case <-s.close: if err := drainBuf(); err != nil {