From 616433124363565c8234001bfe17161384725127 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BF=97=E5=AE=87?= Date: Wed, 4 Mar 2020 19:54:14 +0800 Subject: [PATCH] Updated error reporting when registering tp during settlement HS. --- go.mod | 2 +- go.sum | 2 ++ pkg/transport/handshake.go | 9 ++++++++- vendor/github.com/SkycoinProject/dmsg/httputil/error.go | 2 +- vendor/modules.txt | 2 +- 5 files changed, 13 insertions(+), 4 deletions(-) diff --git a/go.mod b/go.mod index 5e5cfff261..df84059f88 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module github.com/SkycoinProject/skywire-mainnet go 1.13 require ( - github.com/SkycoinProject/dmsg v0.0.0-20200304081751-cf4d40f5428f + github.com/SkycoinProject/dmsg v0.0.0-20200304115237-130cc9d98ffb github.com/SkycoinProject/skycoin v0.27.0 github.com/SkycoinProject/yamux v0.0.0-20191213015001-a36efeefbf6a github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5 diff --git a/go.sum b/go.sum index faf5720174..7220fb7412 100644 --- a/go.sum +++ b/go.sum @@ -3,6 +3,8 @@ github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03 github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU= github.com/SkycoinProject/dmsg v0.0.0-20200304081751-cf4d40f5428f h1:NvirKQPrsp9xrJItJfmRwhfY7atS/AuzdGmJ76m703M= github.com/SkycoinProject/dmsg v0.0.0-20200304081751-cf4d40f5428f/go.mod h1:DzykXMLlx6Fx0fGjZsCIRas/MIvxW8DZpmDA6f2nCRk= +github.com/SkycoinProject/dmsg v0.0.0-20200304115237-130cc9d98ffb h1:UPgo4kZ/nFV4jI9djG0esOyZjda4IZGZpGl/ntYRyuM= +github.com/SkycoinProject/dmsg v0.0.0-20200304115237-130cc9d98ffb/go.mod h1:DzykXMLlx6Fx0fGjZsCIRas/MIvxW8DZpmDA6f2nCRk= github.com/SkycoinProject/skycoin v0.26.0/go.mod h1:xqPLOKh5B6GBZlGA7B5IJfQmCy7mwimD9NlqxR3gMXo= github.com/SkycoinProject/skycoin v0.27.0 h1:N3IHxj8ossHOcsxLYOYugT+OaELLncYHJHxbbYLPPmY= github.com/SkycoinProject/skycoin v0.27.0/go.mod h1:xqPLOKh5B6GBZlGA7B5IJfQmCy7mwimD9NlqxR3gMXo= diff --git a/pkg/transport/handshake.go b/pkg/transport/handshake.go index cf9d52a886..e18dc02e30 100644 --- a/pkg/transport/handshake.go +++ b/pkg/transport/handshake.go @@ -6,8 +6,10 @@ import ( "errors" "fmt" "io" + "net/http" "github.com/SkycoinProject/dmsg/cipher" + "github.com/SkycoinProject/dmsg/httputil" "github.com/SkycoinProject/skywire-mainnet/pkg/snet" ) @@ -130,7 +132,12 @@ func MakeSettlementHS(init bool) SettlementHS { // Ensure transport is registered. if err := dc.RegisterTransports(ctx, recvSE); err != nil { - log.WithError(err).Error("Failed to register transports") + if httpErr, ok := err.(*httputil.HTTPError); ok && httpErr.Status == http.StatusConflict { + log.WithError(err).Debug("An expected error occurred while trying to register transport.") + } else { + // TODO(evanlinjin): Once tpDisc is updated, this should return error and result in failed HS. + log.WithError(err).Error("Failed to register transport.") + } } // inform initiating visor. diff --git a/vendor/github.com/SkycoinProject/dmsg/httputil/error.go b/vendor/github.com/SkycoinProject/dmsg/httputil/error.go index 6060dd66a0..5b545990a2 100644 --- a/vendor/github.com/SkycoinProject/dmsg/httputil/error.go +++ b/vendor/github.com/SkycoinProject/dmsg/httputil/error.go @@ -27,7 +27,7 @@ func ErrorFromResp(resp *http.Response) error { // Error returns the error message. func (e *HTTPError) Error() string { - return fmt.Sprintf("(%d)%s: %v", e.Status, http.StatusText(e.Status), e.Body) + return fmt.Sprintf("%d %s: %v", e.Status, http.StatusText(e.Status), e.Body) } // Timeout implements net.Error diff --git a/vendor/modules.txt b/vendor/modules.txt index 176ebd069f..2ece7f09d8 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -1,4 +1,4 @@ -# github.com/SkycoinProject/dmsg v0.0.0-20200304081751-cf4d40f5428f +# github.com/SkycoinProject/dmsg v0.0.0-20200304115237-130cc9d98ffb github.com/SkycoinProject/dmsg github.com/SkycoinProject/dmsg/cipher github.com/SkycoinProject/dmsg/disc