diff --git a/cmd/di.go b/cmd/di.go index 4ac3a88f7c..1088d8ce3c 100644 --- a/cmd/di.go +++ b/cmd/di.go @@ -20,12 +20,6 @@ package cmd import ( "fmt" "net" - - "github.com/mysteriumnetwork/node/core/monitoring" - - "github.com/mysteriumnetwork/node/core/policy" - "github.com/mysteriumnetwork/node/core/policy/localcopy" - "net/http" "net/url" "path/filepath" @@ -49,8 +43,11 @@ import ( "github.com/mysteriumnetwork/node/core/discovery/proposal" "github.com/mysteriumnetwork/node/core/ip" "github.com/mysteriumnetwork/node/core/location" + "github.com/mysteriumnetwork/node/core/monitoring" "github.com/mysteriumnetwork/node/core/node" nodevent "github.com/mysteriumnetwork/node/core/node/event" + "github.com/mysteriumnetwork/node/core/policy" + "github.com/mysteriumnetwork/node/core/policy/localcopy" "github.com/mysteriumnetwork/node/core/port" "github.com/mysteriumnetwork/node/core/quality" "github.com/mysteriumnetwork/node/core/service" @@ -892,7 +889,7 @@ func (di *Dependencies) bootstrapQualityComponents(options node.OptionsQuality) } di.QualityClient = quality.NewMorqaClient( - requests.NewHTTPClientWithTransport(di.HTTPTransport, 10*time.Second), + requests.NewHTTPClientWithTransport(di.HTTPTransport, 60*time.Second), options.Address, di.SignerFactory, ) diff --git a/core/quality/mysterium_morqa.go b/core/quality/mysterium_morqa.go index 920f4f78fa..0e9f3ffe36 100644 --- a/core/quality/mysterium_morqa.go +++ b/core/quality/mysterium_morqa.go @@ -528,6 +528,10 @@ func (m *MysteriumMORQA) newRequestBinary(method, path string, payload proto.Mes } func (m *MysteriumMORQA) doRequestAndCacheResponse(request *http.Request, ttl time.Duration, dto interface{}) error { + if err, ok := m.cache.Get("err" + request.URL.RequestURI()); ok { + return err.(error) + } + if resp, ok := m.cache.Get(request.URL.RequestURI()); ok { serializedDTO, err := json.Marshal(resp) if err != nil { @@ -539,6 +543,7 @@ func (m *MysteriumMORQA) doRequestAndCacheResponse(request *http.Request, ttl ti response, err := m.client.Do(request) if err != nil { + m.cache.Set("err"+request.URL.RequestURI(), err, ttl) log.Warn().Err(err).Msg("Failed to request proposals quality") return nil @@ -546,6 +551,7 @@ func (m *MysteriumMORQA) doRequestAndCacheResponse(request *http.Request, ttl ti defer response.Body.Close() if err := parseResponseJSON(response, dto); err != nil { + m.cache.Set("err"+request.URL.RequestURI(), err, ttl) return err }