Skip to content

Commit

Permalink
add packetLoss parameter to Quality
Browse files Browse the repository at this point in the history
  • Loading branch information
yeszhanov95 committed Oct 23, 2024
1 parent fc8bd99 commit 1028813
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 8 deletions.
1 change: 1 addition & 0 deletions proposal/metrics/enhancer.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ func EnhanceWithMetrics(proposals []v3.Proposal, or map[string]*oracleapi.Detail
p.Quality.Latency = q.Latency
p.Quality.Bandwidth = q.Bandwidth
p.Quality.Uptime = q.Uptime
p.Quality.PacketLoss = q.PacketLoss
p.Quality.MonitoringFailed = q.MonitoringFailed

if !matchPreset(f.PresetID, p) {
Expand Down
12 changes: 6 additions & 6 deletions proposal/v3/metadata_json.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions proposal/v3/proposal.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,8 @@ type Quality struct {
Bandwidth float64 `json:"bandwidth"`
// Uptime in hours per day
Uptime float64 `json:"uptime"`
// PacketLoss in percantage
PacketLoss float64 `json:"packetLoss"`
// MonitoringFailed did monitoring agent succeed to connect to the node.
MonitoringFailed bool `json:"monitoring_failed,omitempty"`
}
7 changes: 7 additions & 0 deletions proposal/v3/proposal_json.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 5 additions & 2 deletions proposal/v3/proposal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@ package v3_test

import (
"encoding/json"
v3 "github.com/mysteriumnetwork/discovery/proposal/v3"
"reflect"
"testing"

v3 "github.com/mysteriumnetwork/discovery/proposal/v3"
)

func TestProposal_MarshalBinary(t *testing.T) {
proposalJson := `{"id":0,"format":"service-proposal/v3","compatibility":2,"provider_id":"0x55d9995cf3482ee0628fe25e3c95a95899f23cad","service_type":"scraping","location":{"continent":"EU","country":"PL","region":"Malopolskie","city":"Nowy Sacz","asn":5617,"isp":"Orange Polska Spolka Akcyjna","ip_type":"residential"},"contacts":[{"type":"nats/p2p/v1","definition":{"broker_addresses":["nats://broker.mysterium.network:4222","nats://broker.mysterium.network:4222","nats://51.15.22.197:4222","nats://51.15.23.12:4222","nats://51.15.23.14:4222","nats://51.15.23.16:4222"]}}],"access_policies":[{"id":"mysterium","source":"https://trust.mysterium.network/api/v1/access-policies/mysterium"}],"quality":{"quality":2.0250000000000004,"latency":824.898867,"bandwidth":10.275812,"uptime":24}}`
proposalJson := `{"id":0,"format":"service-proposal/v3","compatibility":2,"provider_id":"0x55d9995cf3482ee0628fe25e3c95a95899f23cad","service_type":"scraping","location":{"continent":"EU","country":"PL","region":"Malopolskie","city":"Nowy Sacz","asn":5617,"isp":"Orange Polska Spolka Akcyjna","ip_type":"residential"},"contacts":[{"type":"nats/p2p/v1","definition":{"broker_addresses":["nats://broker.mysterium.network:4222","nats://broker.mysterium.network:4222","nats://51.15.22.197:4222","nats://51.15.23.12:4222","nats://51.15.23.14:4222","nats://51.15.23.16:4222"]}}],"access_policies":[{"id":"mysterium","source":"https://trust.mysterium.network/api/v1/access-policies/mysterium"}],"quality":{"quality":2.0250000000000004,"latency":824.898867,"bandwidth":10.275812,"uptime":24,"packetLoss":0.5}}`
def := json.RawMessage(`{
"broker_addresses": [
"nats://broker.mysterium.network:4222",
Expand Down Expand Up @@ -51,6 +52,7 @@ func TestProposal_MarshalBinary(t *testing.T) {
Latency: 824.898867,
Bandwidth: 10.275812,
Uptime: 24,
PacketLoss: 0.5,
MonitoringFailed: false,
},
}
Expand Down Expand Up @@ -97,6 +99,7 @@ func BenchmarkProposal_UnmarshalBinary(b *testing.B) {
Latency: 497.234331,
Bandwidth: 1.825416,
Uptime: 24,
PacketLoss: 0.5,
MonitoringFailed: true,
},
}
Expand Down
1 change: 1 addition & 0 deletions quality/oracleapi/oracle.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ type DetailedQuality struct {
Latency float64 `json:"latency" example:"75.5"`
Uptime float64 `json:"uptime" example:"7.7"`
Bandwidth float64 `json:"bandwidth" example:"15.5"`
PacketLoss float64 `json:"packetLoss" example:"0.5"`
}

// CountryLoad represents the ratio of providers to active sessions for country.
Expand Down

0 comments on commit 1028813

Please sign in to comment.