diff --git a/models/peer/peer.go b/models/peer/peer.go index b18ca50..ed9e949 100644 --- a/models/peer/peer.go +++ b/models/peer/peer.go @@ -51,6 +51,23 @@ type BehaviorWarning struct { Evidence string `json:"evidence,omitempty" bson:"evidence,omitempty"` } +// PeerLocation holds the voluntarily disclosed geographic position of a node. +// Granularity controls how precise the location is: +// +// 0 = not disclosed +// 1 = continent (±15°) +// 2 = country (±3°) — default +// 3 = region (±0.5°) +// 4 = city (±0.05°) +// +// The coordinates are always fuzzed by oc-discovery before publication, +// so a granularity-2 location identifies only the rough country area. +type PeerLocation struct { + Latitude float64 `json:"latitude" bson:"latitude"` + Longitude float64 `json:"longitude" bson:"longitude"` + Granularity int `json:"granularity" bson:"granularity"` +} + // Peer is a struct that represents a peer type Peer struct { utils.AbstractObject @@ -68,6 +85,9 @@ type Peer struct { ServicesState map[string]int `json:"services_state,omitempty" bson:"services_state,omitempty"` FailedExecution []PeerExecution `json:"failed_execution" bson:"failed_execution"` // FailedExecution is the list of failed executions, to be retried + // Location is the voluntarily disclosed (and fuzzed) geographic position. + Location *PeerLocation `json:"location,omitempty" bson:"location,omitempty"` + // Trust scoring — maintained by oc-discovery from PEER_BEHAVIOR_EVENT reports. TrustScore float64 `json:"trust_score" bson:"trust_score" default:"100"` BlacklistReason string `json:"blacklist_reason,omitempty" bson:"blacklist_reason,omitempty"`