-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathweights.go
34 lines (31 loc) · 1.34 KB
/
weights.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
package gonion
// GetWeights returns results from https://onionoo.torproject.org/weights.
func GetWeights(client HTTPClient, args Params) (*Weights, error) {
weights := &Weights{}
err := getEndp(client, "weights", args, weights)
if err != nil {
return nil, err
}
return weights, nil
}
// Weights represents the datastructure defined by Onionoo.
// See https://metrics.torproject.org/onionoo.html#weights.
type Weights struct {
Version string `json:"version"`
BuildRevision string `json:"build_revision"`
RelaysPublished string `json:"relays_published"`
RelaysSkipped *int `json:"relays_skipped,omitempty"`
Relays []WeightNode `json:"relays"`
RelaysTruncated *int `json:"relays_truncated,omitempty"`
BridgesPublished string `json:"bridges_published"`
Bridges []WeightNode `json:"bridges"`
}
// WeightNode is a sub-Weights datastructure.
type WeightNode struct {
Fingerprint string `json:"fingerprint"`
ConsensusWeightFraction *History `json:"consensus_weight_fraction,omitempty"`
GuardProbability *History `json:"guard_probability,omitempty"`
MiddleProbability *History `json:"middle_probability,omitempty"`
ExitProbability *History `json:"exit_probability,omitempty"`
ConsensusWeight *History `json:"consensus_weight,omitempty"`
}