diff --git a/README.md b/README.md index 7e07e0d..c757474 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ ### Features * Fetch MYST prices from the public API * Create prices for nodes based on the load and multiplier in the countries -* Listen for proposals from NATS Broker and enhance them with quality metrics and tags +* Listen for proposals from NATS Broker and enhance them with quality metrics * Run proposal expiration job * Update price config by Universe Admin * Use Postgres to save proposals, configs, and country multipliers @@ -27,7 +27,6 @@ MYSTERIUM_LOG_MODE=json PORT=8080 QUALITY_ORACLE_URL=https://testnet3-quality.mysterium.network QUALITY_CACHE_TTL=20s -BADGER_ADDRESS=https://testnet3-badger.mysterium.network BROKER_URL=nats://testnet3-broker.mysterium.network UNIVERSE_JWT_SECRET=Some_Secret REDIS_ADDRESS=redis:6379 @@ -63,7 +62,6 @@ COINRANKING_TOKEN=Some_Token #### Code structure * `/config` - [Discovery] config parser. Env params -* `/tags` - [Discovery] Tags proposals enhancer for SuperProxy * `/docs` - [Discovery] Auto generated Swagger for REST API * `/e2e` - e2e tests * `/health` - [Discovery] health checker REST API diff --git a/cmd/main.go b/cmd/main.go index f369cd3..0cde185 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -25,7 +25,6 @@ import ( "github.com/mysteriumnetwork/discovery/proposal" "github.com/mysteriumnetwork/discovery/quality" "github.com/mysteriumnetwork/discovery/quality/oracleapi" - "github.com/mysteriumnetwork/discovery/tags" "github.com/mysteriumnetwork/go-rest/apierror" mlog "github.com/mysteriumnetwork/logger" ) @@ -62,8 +61,7 @@ func main() { pprof.RouteRegister(devGroup, "pprof") } - tagEnhancer := tags.NewEnhancer(tags.NewApi(cfg.BadgerAddress.String())) - proposalRepo := proposal.NewRepository([]proposal.Enhancer{tagEnhancer}, cfg.ProposalsHardLimitPerCountry, cfg.ProposalsSoftLimitPerCountry, cfg.CompatibilityMin) + proposalRepo := proposal.NewRepository(cfg.ProposalsHardLimitPerCountry, cfg.ProposalsSoftLimitPerCountry, cfg.CompatibilityMin) qualityOracleAPI := oracleapi.New(cfg.QualityOracleURL.String()) qualityService := quality.NewService(qualityOracleAPI, cfg.QualityCacheTTL) proposalService := proposal.NewService(proposalRepo, qualityService) diff --git a/config/options.go b/config/options.go index 6c021e6..fbf1809 100644 --- a/config/options.go +++ b/config/options.go @@ -25,8 +25,6 @@ type Options struct { RedisPass string RedisDB int - BadgerAddress url.URL - LocationAddress url.URL LocationUser string LocationPass string @@ -74,10 +72,6 @@ func ReadDiscovery() (*Options, error) { if err != nil { return nil, err } - badgerAddress, err := RequiredEnvURL("BADGER_ADDRESS") - if err != nil { - return nil, err - } compatibility, err := OptionalEnvInt("COMPATIBILITY_MIN", "0") if err != nil { @@ -114,7 +108,6 @@ func ReadDiscovery() (*Options, error) { QualityOracleURL: *qualityOracleURL, QualityCacheTTL: *qualityCacheTTL, BrokerURL: *brokerURL, - BadgerAddress: *badgerAddress, LocationAddress: *locationAddress, LocationUser: locationUser, LocationPass: locationPass, diff --git a/docker-compose.yml b/docker-compose.yml index e1cf24e..b88400f 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -14,7 +14,6 @@ services: - PORT=8080 - QUALITY_ORACLE_URL=https://quality.mysterium.network - QUALITY_CACHE_TTL=20s - - BADGER_ADDRESS=https://badger.mysterium.network - BROKER_URL=nats://broker.mysterium.network - UNIVERSE_JWT_SECRET=suchsecret - REDIS_ADDRESS=redis:6379 diff --git a/e2e/api.go b/e2e/api.go index 1daa4ba..928953f 100644 --- a/e2e/api.go +++ b/e2e/api.go @@ -11,8 +11,10 @@ import ( v3 "github.com/mysteriumnetwork/discovery/proposal/v3" ) -var DiscoveryAPI = newDiscoveryAPI(DiscoveryAPIurl) -var PricerAPI = newPricingAPI(PricerAPIUrl) +var ( + DiscoveryAPI = newDiscoveryAPI(DiscoveryAPIurl) + PricerAPI = newPricingAPI(PricerAPIUrl) +) func newDiscoveryAPI(basePath string) *discoveryAPI { return &discoveryAPI{ @@ -47,7 +49,6 @@ type Query struct { CompatibilityMin int `url:"compatibility_min"` CompatibilityMax int `url:"compatibility_max"` QualityMin float64 `url:"quality_min"` - Tags string `url:"tags"` IncludeMonitoringFailed bool `url:"include_monitoring_failed"` NATCompatibility string `url:"nat_compatibility"` } diff --git a/e2e/docker-compose.yml b/e2e/docker-compose.yml index 1fc84f8..fb7d481 100644 --- a/e2e/docker-compose.yml +++ b/e2e/docker-compose.yml @@ -11,7 +11,6 @@ services: - QUALITY_ORACLE_URL=http://wiremock:8080 - QUALITY_CACHE_TTL=1s - PROPOSALS_CACHE_TTL=0s - - BADGER_ADDRESS=http://wiremock:8080 - BROKER_URL=nats://broker - LOCATION_ADDRESS=http://wiremock:8080 - UNIVERSE_JWT_SECRET=suchsecret @@ -35,7 +34,6 @@ services: - PORT=8081 - QUALITY_ORACLE_URL=http://wiremock:8004 - QUALITY_CACHE_TTL=20s - - BADGER_ADDRESS=http://wiremock:8004 - SENTINEL_URL=http://wiremock:8004 - BROKER_URL=nats://broker.mysterium.network - UNIVERSE_JWT_SECRET=suchsecret diff --git a/e2e/wiremock/mappings/tag.json b/e2e/wiremock/mappings/tag.json deleted file mode 100644 index 608ec55..0000000 --- a/e2e/wiremock/mappings/tag.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "request": { - "method": "GET", - "urlPattern": "/api/v1/tags/provider.*" - }, - "response": { - "status": 200, - "headers": { - "Content-Type": "application/json; charset=utf-8" - }, - "jsonBody": { - "tags": ["test", "maybe"] - } - } -} \ No newline at end of file diff --git a/magefile.go b/magefile.go index de844f8..eb256e3 100644 --- a/magefile.go +++ b/magefile.go @@ -86,7 +86,6 @@ func Run() error { "COINRANKING_TOKEN": "", "UNIVERSE_JWT_SECRET": "", "REDIS_ADDRESS": "localhost:6379", - "BADGER_ADDRESS": "https://badger.mysterium.network", "LOCATION_ADDRESS": "https://location.mysterium.network/api/v1/location", "SENTINEL_URL": "https://sentinel.mysterium.network", } diff --git a/proposal/api.go b/proposal/api.go index afbfc63..d51eb85 100644 --- a/proposal/api.go +++ b/proposal/api.go @@ -206,7 +206,6 @@ func (a *API) proposalArgs(c *gin.Context) ListOpts { accessPolicy: c.Query("access_policy"), accessPolicySource: c.Query("access_policy_source"), ipType: c.Query("ip_type"), - tags: c.Query("tags"), } pids, _ := c.GetQueryArray("provider_id") diff --git a/proposal/inmemory.go b/proposal/inmemory.go index 53fcae5..f8df535 100644 --- a/proposal/inmemory.go +++ b/proposal/inmemory.go @@ -6,7 +6,6 @@ package proposal import ( "errors" - "strings" "sync" "time" @@ -25,7 +24,6 @@ type Repository struct { expirationDuration time.Duration mu sync.RWMutex proposals map[string]record - enhancers []Enhancer proposalsHardLimitPerCountry int proposalsSoftLimitPerCountry int compatibilityMin int @@ -40,7 +38,6 @@ type repoListOpts struct { accessPolicySource string compatibilityMin int compatibilityMax int - tags string } type repoMetadataOpts struct { @@ -52,12 +49,11 @@ type record struct { expiresAt time.Time } -func NewRepository(enhancers []Enhancer, proposalsHardLimitPerCountry, proposalsSoftLimitPerCountry, compatibilityMin int) *Repository { +func NewRepository(proposalsHardLimitPerCountry, proposalsSoftLimitPerCountry, compatibilityMin int) *Repository { return &Repository{ expirationDuration: 3*time.Minute + 10*time.Second, expirationJobDelay: 20 * time.Second, proposals: make(map[string]record), - enhancers: enhancers, proposalsHardLimitPerCountry: proposalsHardLimitPerCountry, proposalsSoftLimitPerCountry: proposalsSoftLimitPerCountry, compatibilityMin: compatibilityMin, @@ -271,21 +267,5 @@ func match(p v3.Proposal, opts repoListOpts) bool { } } - if opts.tags != "" { - found := false - - for _, ot := range strings.Split(opts.tags, ",") { - for _, pt := range p.Tags { - if ot == pt { - found = true - } - } - } - - if !found { - return false - } - } - return true } diff --git a/proposal/service.go b/proposal/service.go index 76ef642..dba3dc1 100644 --- a/proposal/service.go +++ b/proposal/service.go @@ -39,7 +39,6 @@ type ListOpts struct { compatibilityMax int bandwidthMin float64 qualityMin float64 - tags string includeMonitoringFailed bool natCompatibility string presetID int @@ -55,7 +54,6 @@ func (s *Service) List(opts ListOpts, limited bool) []v3.Proposal { accessPolicySource: opts.accessPolicySource, compatibilityMin: opts.compatibilityMin, compatibilityMax: opts.compatibilityMax, - tags: opts.tags, }, limited) or := &metrics.OracleResponses{} @@ -88,7 +86,6 @@ func (s *Service) ListCountriesNumbers(opts ListOpts, limited bool) map[string]i accessPolicySource: opts.accessPolicySource, compatibilityMin: opts.compatibilityMin, compatibilityMax: opts.compatibilityMax, - tags: opts.tags, }) } @@ -101,7 +98,6 @@ func (s *Service) ListCountriesNumbers(opts ListOpts, limited bool) map[string]i accessPolicySource: opts.accessPolicySource, compatibilityMin: opts.compatibilityMin, compatibilityMax: opts.compatibilityMax, - tags: opts.tags, }, limited) or := &metrics.OracleResponses{} diff --git a/proposal/v3/proposal.go b/proposal/v3/proposal.go index bfc48b7..2cb179c 100644 --- a/proposal/v3/proposal.go +++ b/proposal/v3/proposal.go @@ -42,7 +42,6 @@ type Proposal struct { Contacts []Contact `json:"contacts"` AccessPolicies []AccessPolicy `json:"access_policies,omitempty"` Quality Quality `json:"quality"` - Tags []string `json:"tags,omitempty"` } func NewProposal(providerID, serviceType string) *Proposal { diff --git a/proposal/v3/proposal_json.go b/proposal/v3/proposal_json.go index 58a78d8..5cb01bd 100644 --- a/proposal/v3/proposal_json.go +++ b/proposal/v3/proposal_json.go @@ -18,7 +18,7 @@ var ( _ easyjson.Marshaler ) -func easyjson316ad6c2DecodeGithubComMysteriumnetworkDiscoveryProposalV3(in *jlexer.Lexer, out *Quality) { +func easyjsonAd058f64DecodeGithubComMysteriumnetworkDiscoveryProposalV3(in *jlexer.Lexer, out *Quality) { isTopLevel := in.IsStart() if in.IsNull() { if isTopLevel { @@ -57,7 +57,7 @@ func easyjson316ad6c2DecodeGithubComMysteriumnetworkDiscoveryProposalV3(in *jlex in.Consumed() } } -func easyjson316ad6c2EncodeGithubComMysteriumnetworkDiscoveryProposalV3(out *jwriter.Writer, in Quality) { +func easyjsonAd058f64EncodeGithubComMysteriumnetworkDiscoveryProposalV3(out *jwriter.Writer, in Quality) { out.RawByte('{') first := true _ = first @@ -92,27 +92,27 @@ func easyjson316ad6c2EncodeGithubComMysteriumnetworkDiscoveryProposalV3(out *jwr // MarshalJSON supports json.Marshaler interface func (v Quality) MarshalJSON() ([]byte, error) { w := jwriter.Writer{} - easyjson316ad6c2EncodeGithubComMysteriumnetworkDiscoveryProposalV3(&w, v) + easyjsonAd058f64EncodeGithubComMysteriumnetworkDiscoveryProposalV3(&w, v) return w.Buffer.BuildBytes(), w.Error } // MarshalEasyJSON supports easyjson.Marshaler interface func (v Quality) MarshalEasyJSON(w *jwriter.Writer) { - easyjson316ad6c2EncodeGithubComMysteriumnetworkDiscoveryProposalV3(w, v) + easyjsonAd058f64EncodeGithubComMysteriumnetworkDiscoveryProposalV3(w, v) } // UnmarshalJSON supports json.Unmarshaler interface func (v *Quality) UnmarshalJSON(data []byte) error { r := jlexer.Lexer{Data: data} - easyjson316ad6c2DecodeGithubComMysteriumnetworkDiscoveryProposalV3(&r, v) + easyjsonAd058f64DecodeGithubComMysteriumnetworkDiscoveryProposalV3(&r, v) return r.Error() } // UnmarshalEasyJSON supports easyjson.Unmarshaler interface func (v *Quality) UnmarshalEasyJSON(l *jlexer.Lexer) { - easyjson316ad6c2DecodeGithubComMysteriumnetworkDiscoveryProposalV3(l, v) + easyjsonAd058f64DecodeGithubComMysteriumnetworkDiscoveryProposalV3(l, v) } -func easyjson316ad6c2DecodeGithubComMysteriumnetworkDiscoveryProposalV31(in *jlexer.Lexer, out *ProposalUnregisterMessage) { +func easyjsonAd058f64DecodeGithubComMysteriumnetworkDiscoveryProposalV31(in *jlexer.Lexer, out *ProposalUnregisterMessage) { isTopLevel := in.IsStart() if in.IsNull() { if isTopLevel { @@ -143,7 +143,7 @@ func easyjson316ad6c2DecodeGithubComMysteriumnetworkDiscoveryProposalV31(in *jle in.Consumed() } } -func easyjson316ad6c2EncodeGithubComMysteriumnetworkDiscoveryProposalV31(out *jwriter.Writer, in ProposalUnregisterMessage) { +func easyjsonAd058f64EncodeGithubComMysteriumnetworkDiscoveryProposalV31(out *jwriter.Writer, in ProposalUnregisterMessage) { out.RawByte('{') first := true _ = first @@ -158,27 +158,27 @@ func easyjson316ad6c2EncodeGithubComMysteriumnetworkDiscoveryProposalV31(out *jw // MarshalJSON supports json.Marshaler interface func (v ProposalUnregisterMessage) MarshalJSON() ([]byte, error) { w := jwriter.Writer{} - easyjson316ad6c2EncodeGithubComMysteriumnetworkDiscoveryProposalV31(&w, v) + easyjsonAd058f64EncodeGithubComMysteriumnetworkDiscoveryProposalV31(&w, v) return w.Buffer.BuildBytes(), w.Error } // MarshalEasyJSON supports easyjson.Marshaler interface func (v ProposalUnregisterMessage) MarshalEasyJSON(w *jwriter.Writer) { - easyjson316ad6c2EncodeGithubComMysteriumnetworkDiscoveryProposalV31(w, v) + easyjsonAd058f64EncodeGithubComMysteriumnetworkDiscoveryProposalV31(w, v) } // UnmarshalJSON supports json.Unmarshaler interface func (v *ProposalUnregisterMessage) UnmarshalJSON(data []byte) error { r := jlexer.Lexer{Data: data} - easyjson316ad6c2DecodeGithubComMysteriumnetworkDiscoveryProposalV31(&r, v) + easyjsonAd058f64DecodeGithubComMysteriumnetworkDiscoveryProposalV31(&r, v) return r.Error() } // UnmarshalEasyJSON supports easyjson.Unmarshaler interface func (v *ProposalUnregisterMessage) UnmarshalEasyJSON(l *jlexer.Lexer) { - easyjson316ad6c2DecodeGithubComMysteriumnetworkDiscoveryProposalV31(l, v) + easyjsonAd058f64DecodeGithubComMysteriumnetworkDiscoveryProposalV31(l, v) } -func easyjson316ad6c2DecodeGithubComMysteriumnetworkDiscoveryProposalV32(in *jlexer.Lexer, out *ProposalPingMessage) { +func easyjsonAd058f64DecodeGithubComMysteriumnetworkDiscoveryProposalV32(in *jlexer.Lexer, out *ProposalPingMessage) { isTopLevel := in.IsStart() if in.IsNull() { if isTopLevel { @@ -209,7 +209,7 @@ func easyjson316ad6c2DecodeGithubComMysteriumnetworkDiscoveryProposalV32(in *jle in.Consumed() } } -func easyjson316ad6c2EncodeGithubComMysteriumnetworkDiscoveryProposalV32(out *jwriter.Writer, in ProposalPingMessage) { +func easyjsonAd058f64EncodeGithubComMysteriumnetworkDiscoveryProposalV32(out *jwriter.Writer, in ProposalPingMessage) { out.RawByte('{') first := true _ = first @@ -224,27 +224,27 @@ func easyjson316ad6c2EncodeGithubComMysteriumnetworkDiscoveryProposalV32(out *jw // MarshalJSON supports json.Marshaler interface func (v ProposalPingMessage) MarshalJSON() ([]byte, error) { w := jwriter.Writer{} - easyjson316ad6c2EncodeGithubComMysteriumnetworkDiscoveryProposalV32(&w, v) + easyjsonAd058f64EncodeGithubComMysteriumnetworkDiscoveryProposalV32(&w, v) return w.Buffer.BuildBytes(), w.Error } // MarshalEasyJSON supports easyjson.Marshaler interface func (v ProposalPingMessage) MarshalEasyJSON(w *jwriter.Writer) { - easyjson316ad6c2EncodeGithubComMysteriumnetworkDiscoveryProposalV32(w, v) + easyjsonAd058f64EncodeGithubComMysteriumnetworkDiscoveryProposalV32(w, v) } // UnmarshalJSON supports json.Unmarshaler interface func (v *ProposalPingMessage) UnmarshalJSON(data []byte) error { r := jlexer.Lexer{Data: data} - easyjson316ad6c2DecodeGithubComMysteriumnetworkDiscoveryProposalV32(&r, v) + easyjsonAd058f64DecodeGithubComMysteriumnetworkDiscoveryProposalV32(&r, v) return r.Error() } // UnmarshalEasyJSON supports easyjson.Unmarshaler interface func (v *ProposalPingMessage) UnmarshalEasyJSON(l *jlexer.Lexer) { - easyjson316ad6c2DecodeGithubComMysteriumnetworkDiscoveryProposalV32(l, v) + easyjsonAd058f64DecodeGithubComMysteriumnetworkDiscoveryProposalV32(l, v) } -func easyjson316ad6c2DecodeGithubComMysteriumnetworkDiscoveryProposalV33(in *jlexer.Lexer, out *Proposal) { +func easyjsonAd058f64DecodeGithubComMysteriumnetworkDiscoveryProposalV33(in *jlexer.Lexer, out *Proposal) { isTopLevel := in.IsStart() if in.IsNull() { if isTopLevel { @@ -323,29 +323,6 @@ func easyjson316ad6c2DecodeGithubComMysteriumnetworkDiscoveryProposalV33(in *jle } case "quality": (out.Quality).UnmarshalEasyJSON(in) - case "tags": - if in.IsNull() { - in.Skip() - out.Tags = nil - } else { - in.Delim('[') - if out.Tags == nil { - if !in.IsDelim(']') { - out.Tags = make([]string, 0, 4) - } else { - out.Tags = []string{} - } - } else { - out.Tags = (out.Tags)[:0] - } - for !in.IsDelim(']') { - var v3 string - v3 = string(in.String()) - out.Tags = append(out.Tags, v3) - in.WantComma() - } - in.Delim(']') - } default: in.SkipRecursive() } @@ -356,7 +333,7 @@ func easyjson316ad6c2DecodeGithubComMysteriumnetworkDiscoveryProposalV33(in *jle in.Consumed() } } -func easyjson316ad6c2EncodeGithubComMysteriumnetworkDiscoveryProposalV33(out *jwriter.Writer, in Proposal) { +func easyjsonAd058f64EncodeGithubComMysteriumnetworkDiscoveryProposalV33(out *jwriter.Writer, in Proposal) { out.RawByte('{') first := true _ = first @@ -397,11 +374,11 @@ func easyjson316ad6c2EncodeGithubComMysteriumnetworkDiscoveryProposalV33(out *jw out.RawString("null") } else { out.RawByte('[') - for v4, v5 := range in.Contacts { - if v4 > 0 { + for v3, v4 := range in.Contacts { + if v3 > 0 { out.RawByte(',') } - (v5).MarshalEasyJSON(out) + (v4).MarshalEasyJSON(out) } out.RawByte(']') } @@ -411,11 +388,11 @@ func easyjson316ad6c2EncodeGithubComMysteriumnetworkDiscoveryProposalV33(out *jw out.RawString(prefix) { out.RawByte('[') - for v6, v7 := range in.AccessPolicies { - if v6 > 0 { + for v5, v6 := range in.AccessPolicies { + if v5 > 0 { out.RawByte(',') } - (v7).MarshalEasyJSON(out) + (v6).MarshalEasyJSON(out) } out.RawByte(']') } @@ -425,47 +402,33 @@ func easyjson316ad6c2EncodeGithubComMysteriumnetworkDiscoveryProposalV33(out *jw out.RawString(prefix) (in.Quality).MarshalEasyJSON(out) } - if len(in.Tags) != 0 { - const prefix string = ",\"tags\":" - out.RawString(prefix) - { - out.RawByte('[') - for v8, v9 := range in.Tags { - if v8 > 0 { - out.RawByte(',') - } - out.String(string(v9)) - } - out.RawByte(']') - } - } out.RawByte('}') } // MarshalJSON supports json.Marshaler interface func (v Proposal) MarshalJSON() ([]byte, error) { w := jwriter.Writer{} - easyjson316ad6c2EncodeGithubComMysteriumnetworkDiscoveryProposalV33(&w, v) + easyjsonAd058f64EncodeGithubComMysteriumnetworkDiscoveryProposalV33(&w, v) return w.Buffer.BuildBytes(), w.Error } // MarshalEasyJSON supports easyjson.Marshaler interface func (v Proposal) MarshalEasyJSON(w *jwriter.Writer) { - easyjson316ad6c2EncodeGithubComMysteriumnetworkDiscoveryProposalV33(w, v) + easyjsonAd058f64EncodeGithubComMysteriumnetworkDiscoveryProposalV33(w, v) } // UnmarshalJSON supports json.Unmarshaler interface func (v *Proposal) UnmarshalJSON(data []byte) error { r := jlexer.Lexer{Data: data} - easyjson316ad6c2DecodeGithubComMysteriumnetworkDiscoveryProposalV33(&r, v) + easyjsonAd058f64DecodeGithubComMysteriumnetworkDiscoveryProposalV33(&r, v) return r.Error() } // UnmarshalEasyJSON supports easyjson.Unmarshaler interface func (v *Proposal) UnmarshalEasyJSON(l *jlexer.Lexer) { - easyjson316ad6c2DecodeGithubComMysteriumnetworkDiscoveryProposalV33(l, v) + easyjsonAd058f64DecodeGithubComMysteriumnetworkDiscoveryProposalV33(l, v) } -func easyjson316ad6c2DecodeGithubComMysteriumnetworkDiscoveryProposalV34(in *jlexer.Lexer, out *Price) { +func easyjsonAd058f64DecodeGithubComMysteriumnetworkDiscoveryProposalV34(in *jlexer.Lexer, out *Price) { isTopLevel := in.IsStart() if in.IsNull() { if isTopLevel { @@ -518,7 +481,7 @@ func easyjson316ad6c2DecodeGithubComMysteriumnetworkDiscoveryProposalV34(in *jle in.Consumed() } } -func easyjson316ad6c2EncodeGithubComMysteriumnetworkDiscoveryProposalV34(out *jwriter.Writer, in Price) { +func easyjsonAd058f64EncodeGithubComMysteriumnetworkDiscoveryProposalV34(out *jwriter.Writer, in Price) { out.RawByte('{') first := true _ = first @@ -546,27 +509,27 @@ func easyjson316ad6c2EncodeGithubComMysteriumnetworkDiscoveryProposalV34(out *jw // MarshalJSON supports json.Marshaler interface func (v Price) MarshalJSON() ([]byte, error) { w := jwriter.Writer{} - easyjson316ad6c2EncodeGithubComMysteriumnetworkDiscoveryProposalV34(&w, v) + easyjsonAd058f64EncodeGithubComMysteriumnetworkDiscoveryProposalV34(&w, v) return w.Buffer.BuildBytes(), w.Error } // MarshalEasyJSON supports easyjson.Marshaler interface func (v Price) MarshalEasyJSON(w *jwriter.Writer) { - easyjson316ad6c2EncodeGithubComMysteriumnetworkDiscoveryProposalV34(w, v) + easyjsonAd058f64EncodeGithubComMysteriumnetworkDiscoveryProposalV34(w, v) } // UnmarshalJSON supports json.Unmarshaler interface func (v *Price) UnmarshalJSON(data []byte) error { r := jlexer.Lexer{Data: data} - easyjson316ad6c2DecodeGithubComMysteriumnetworkDiscoveryProposalV34(&r, v) + easyjsonAd058f64DecodeGithubComMysteriumnetworkDiscoveryProposalV34(&r, v) return r.Error() } // UnmarshalEasyJSON supports easyjson.Unmarshaler interface func (v *Price) UnmarshalEasyJSON(l *jlexer.Lexer) { - easyjson316ad6c2DecodeGithubComMysteriumnetworkDiscoveryProposalV34(l, v) + easyjsonAd058f64DecodeGithubComMysteriumnetworkDiscoveryProposalV34(l, v) } -func easyjson316ad6c2DecodeGithubComMysteriumnetworkDiscoveryProposalV35(in *jlexer.Lexer, out *Location) { +func easyjsonAd058f64DecodeGithubComMysteriumnetworkDiscoveryProposalV35(in *jlexer.Lexer, out *Location) { isTopLevel := in.IsStart() if in.IsNull() { if isTopLevel { @@ -609,7 +572,7 @@ func easyjson316ad6c2DecodeGithubComMysteriumnetworkDiscoveryProposalV35(in *jle in.Consumed() } } -func easyjson316ad6c2EncodeGithubComMysteriumnetworkDiscoveryProposalV35(out *jwriter.Writer, in Location) { +func easyjsonAd058f64EncodeGithubComMysteriumnetworkDiscoveryProposalV35(out *jwriter.Writer, in Location) { out.RawByte('{') first := true _ = first @@ -685,27 +648,27 @@ func easyjson316ad6c2EncodeGithubComMysteriumnetworkDiscoveryProposalV35(out *jw // MarshalJSON supports json.Marshaler interface func (v Location) MarshalJSON() ([]byte, error) { w := jwriter.Writer{} - easyjson316ad6c2EncodeGithubComMysteriumnetworkDiscoveryProposalV35(&w, v) + easyjsonAd058f64EncodeGithubComMysteriumnetworkDiscoveryProposalV35(&w, v) return w.Buffer.BuildBytes(), w.Error } // MarshalEasyJSON supports easyjson.Marshaler interface func (v Location) MarshalEasyJSON(w *jwriter.Writer) { - easyjson316ad6c2EncodeGithubComMysteriumnetworkDiscoveryProposalV35(w, v) + easyjsonAd058f64EncodeGithubComMysteriumnetworkDiscoveryProposalV35(w, v) } // UnmarshalJSON supports json.Unmarshaler interface func (v *Location) UnmarshalJSON(data []byte) error { r := jlexer.Lexer{Data: data} - easyjson316ad6c2DecodeGithubComMysteriumnetworkDiscoveryProposalV35(&r, v) + easyjsonAd058f64DecodeGithubComMysteriumnetworkDiscoveryProposalV35(&r, v) return r.Error() } // UnmarshalEasyJSON supports easyjson.Unmarshaler interface func (v *Location) UnmarshalEasyJSON(l *jlexer.Lexer) { - easyjson316ad6c2DecodeGithubComMysteriumnetworkDiscoveryProposalV35(l, v) + easyjsonAd058f64DecodeGithubComMysteriumnetworkDiscoveryProposalV35(l, v) } -func easyjson316ad6c2DecodeGithubComMysteriumnetworkDiscoveryProposalV36(in *jlexer.Lexer, out *Contact) { +func easyjsonAd058f64DecodeGithubComMysteriumnetworkDiscoveryProposalV36(in *jlexer.Lexer, out *Contact) { isTopLevel := in.IsStart() if in.IsNull() { if isTopLevel { @@ -748,7 +711,7 @@ func easyjson316ad6c2DecodeGithubComMysteriumnetworkDiscoveryProposalV36(in *jle in.Consumed() } } -func easyjson316ad6c2EncodeGithubComMysteriumnetworkDiscoveryProposalV36(out *jwriter.Writer, in Contact) { +func easyjsonAd058f64EncodeGithubComMysteriumnetworkDiscoveryProposalV36(out *jwriter.Writer, in Contact) { out.RawByte('{') first := true _ = first @@ -772,27 +735,27 @@ func easyjson316ad6c2EncodeGithubComMysteriumnetworkDiscoveryProposalV36(out *jw // MarshalJSON supports json.Marshaler interface func (v Contact) MarshalJSON() ([]byte, error) { w := jwriter.Writer{} - easyjson316ad6c2EncodeGithubComMysteriumnetworkDiscoveryProposalV36(&w, v) + easyjsonAd058f64EncodeGithubComMysteriumnetworkDiscoveryProposalV36(&w, v) return w.Buffer.BuildBytes(), w.Error } // MarshalEasyJSON supports easyjson.Marshaler interface func (v Contact) MarshalEasyJSON(w *jwriter.Writer) { - easyjson316ad6c2EncodeGithubComMysteriumnetworkDiscoveryProposalV36(w, v) + easyjsonAd058f64EncodeGithubComMysteriumnetworkDiscoveryProposalV36(w, v) } // UnmarshalJSON supports json.Unmarshaler interface func (v *Contact) UnmarshalJSON(data []byte) error { r := jlexer.Lexer{Data: data} - easyjson316ad6c2DecodeGithubComMysteriumnetworkDiscoveryProposalV36(&r, v) + easyjsonAd058f64DecodeGithubComMysteriumnetworkDiscoveryProposalV36(&r, v) return r.Error() } // UnmarshalEasyJSON supports easyjson.Unmarshaler interface func (v *Contact) UnmarshalEasyJSON(l *jlexer.Lexer) { - easyjson316ad6c2DecodeGithubComMysteriumnetworkDiscoveryProposalV36(l, v) + easyjsonAd058f64DecodeGithubComMysteriumnetworkDiscoveryProposalV36(l, v) } -func easyjson316ad6c2DecodeGithubComMysteriumnetworkDiscoveryProposalV37(in *jlexer.Lexer, out *AccessPolicy) { +func easyjsonAd058f64DecodeGithubComMysteriumnetworkDiscoveryProposalV37(in *jlexer.Lexer, out *AccessPolicy) { isTopLevel := in.IsStart() if in.IsNull() { if isTopLevel { @@ -825,7 +788,7 @@ func easyjson316ad6c2DecodeGithubComMysteriumnetworkDiscoveryProposalV37(in *jle in.Consumed() } } -func easyjson316ad6c2EncodeGithubComMysteriumnetworkDiscoveryProposalV37(out *jwriter.Writer, in AccessPolicy) { +func easyjsonAd058f64EncodeGithubComMysteriumnetworkDiscoveryProposalV37(out *jwriter.Writer, in AccessPolicy) { out.RawByte('{') first := true _ = first @@ -845,23 +808,23 @@ func easyjson316ad6c2EncodeGithubComMysteriumnetworkDiscoveryProposalV37(out *jw // MarshalJSON supports json.Marshaler interface func (v AccessPolicy) MarshalJSON() ([]byte, error) { w := jwriter.Writer{} - easyjson316ad6c2EncodeGithubComMysteriumnetworkDiscoveryProposalV37(&w, v) + easyjsonAd058f64EncodeGithubComMysteriumnetworkDiscoveryProposalV37(&w, v) return w.Buffer.BuildBytes(), w.Error } // MarshalEasyJSON supports easyjson.Marshaler interface func (v AccessPolicy) MarshalEasyJSON(w *jwriter.Writer) { - easyjson316ad6c2EncodeGithubComMysteriumnetworkDiscoveryProposalV37(w, v) + easyjsonAd058f64EncodeGithubComMysteriumnetworkDiscoveryProposalV37(w, v) } // UnmarshalJSON supports json.Unmarshaler interface func (v *AccessPolicy) UnmarshalJSON(data []byte) error { r := jlexer.Lexer{Data: data} - easyjson316ad6c2DecodeGithubComMysteriumnetworkDiscoveryProposalV37(&r, v) + easyjsonAd058f64DecodeGithubComMysteriumnetworkDiscoveryProposalV37(&r, v) return r.Error() } // UnmarshalEasyJSON supports easyjson.Unmarshaler interface func (v *AccessPolicy) UnmarshalEasyJSON(l *jlexer.Lexer) { - easyjson316ad6c2DecodeGithubComMysteriumnetworkDiscoveryProposalV37(l, v) + easyjsonAd058f64DecodeGithubComMysteriumnetworkDiscoveryProposalV37(l, v) } diff --git a/tags/api.go b/tags/api.go deleted file mode 100644 index acaceff..0000000 --- a/tags/api.go +++ /dev/null @@ -1,43 +0,0 @@ -package tags - -import ( - "encoding/json" - "fmt" - "net/http" - "time" -) - -type API struct { - url string - client *http.Client -} - -type TagResponse struct { - Tags []string `json:"tags,omitempty"` -} - -func NewApi(url string) *API { - return &API{ - url: url, - client: &http.Client{ - Timeout: 5 * time.Second, - }, - } -} - -func (api *API) GetTags(providerID string) ([]string, error) { - resp, err := api.client.Get(fmt.Sprintf("%v/api/v1/tags/provider/%v", api.url, providerID)) - if err != nil { - return nil, fmt.Errorf("request failed: %w", err) - } - defer resp.Body.Close() - if resp.StatusCode < 200 || resp.StatusCode > 299 { - return nil, fmt.Errorf("received response code: %v", resp.StatusCode) - } - - var res TagResponse - if err := json.NewDecoder(resp.Body).Decode(&res); err != nil { - return nil, fmt.Errorf("failed to decode response: %w", err) - } - return res.Tags, nil -} diff --git a/tags/tag_enhancer.go b/tags/tag_enhancer.go deleted file mode 100644 index b2de5d4..0000000 --- a/tags/tag_enhancer.go +++ /dev/null @@ -1,30 +0,0 @@ -package tags - -import ( - v3 "github.com/mysteriumnetwork/discovery/proposal/v3" - "github.com/rs/zerolog/log" -) - -type tagAPI interface { - GetTags(providerID string) ([]string, error) -} - -type Enhancer struct { - tagAPI tagAPI -} - -func NewEnhancer(tagAPI tagAPI) *Enhancer { - return &Enhancer{ - tagAPI: tagAPI, - } -} - -func (e *Enhancer) Enhance(proposal *v3.Proposal) { - tags, err := e.tagAPI.GetTags(proposal.ProviderID) - if err != nil { - log.Error().Err(err).Str("providerID", proposal.ProviderID).Msg("could not get tags") - return - } - - proposal.Tags = tags -}