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 1/3] 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 5e5cfff26..df84059f8 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 faf572017..7220fb741 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 cf9d52a88..e18dc02e3 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 6060dd66a..5b545990a 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 176ebd069..2ece7f09d 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 From 5315750849b37379a3b47f44def55650513e788e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BF=97=E5=AE=87?= Date: Wed, 4 Mar 2020 19:58:09 +0800 Subject: [PATCH 2/3] Tweaks. --- pkg/transport/handshake.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/transport/handshake.go b/pkg/transport/handshake.go index e18dc02e3..f6c67a9f8 100644 --- a/pkg/transport/handshake.go +++ b/pkg/transport/handshake.go @@ -135,7 +135,7 @@ func MakeSettlementHS(init bool) SettlementHS { 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. + // TODO(evanlinjin): In the future, this should return error and result in failed HS. log.WithError(err).Error("Failed to register transport.") } } From 992f013ac50f8328d87138c2ae8645c8941eeae1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BF=97=E5=AE=87?= Date: Wed, 4 Mar 2020 19:58:32 +0800 Subject: [PATCH 3/3] Tidy vendor --- go.sum | 2 -- 1 file changed, 2 deletions(-) diff --git a/go.sum b/go.sum index 7220fb741..4f8b15bed 100644 --- a/go.sum +++ b/go.sum @@ -1,8 +1,6 @@ cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= 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=