-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathnetwork_data.go
70 lines (62 loc) · 2.12 KB
/
network_data.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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
package node
import "github.com/pkg/errors"
// Connection -
type Connection struct {
PeerID string `json:"peer_id"`
Point Point `json:"id_point"`
RemoteSocketPort int `json:"remote_socket_port"`
AnnouncedVersion ConnectionVersion `json:"announced_version"`
LocalMetadata ConnectionMetadata `json:"local_metadata"`
RemoteMetadata ConnectionMetadata `json:"remote_metadata"`
Incoming bool `json:"incoming"`
Private bool `json:"private"`
}
// Point -
type Point struct {
Addr string `json:"addr"`
Port int `json:"port"`
}
// ConnectionMetadata -
type ConnectionMetadata struct {
DisableMempool bool `json:"disable_mempool"`
PrivateNode bool `json:"private_node"`
}
// ConnectionVersion -
type ConnectionVersion struct {
ChainName string `json:"chain_name"`
DistributedDbVersion int `json:"distributed_db_version"`
P2PVersion int `json:"p2p_version"`
}
// NetworkPointWithURI -
type NetworkPointWithURI struct {
URI string
NetworkPoint
}
// UnmarshalJSON -
func (n *NetworkPointWithURI) UnmarshalJSON(buf []byte) error {
tmp := []interface{}{&n.URI, &n.NetworkPoint}
wantLen := len(tmp)
if err := json.Unmarshal(buf, &tmp); err != nil {
return err
}
if g, e := len(tmp), wantLen; g != e {
return errors.Errorf("wrong number of fields in NetworkPointWithURI: %d != %d", g, e)
}
return nil
}
// NetworkPoint -
type NetworkPoint struct {
Trusted bool `json:"trusted"`
GreylistedUntil string `json:"greylisted_until"`
State struct {
EventKind string `json:"event_kind"`
P2PPeerID string `json:"p2p_peer_id"`
} `json:"state"`
P2PPeerID string `json:"p2p_peer_id"`
LastFailedConnection string `json:"last_failed_connection"`
LastRejectedConnection []string `json:"last_rejected_connection"`
LastEstablishedConnection []string `json:"last_established_connection"`
LastDisconnection []string `json:"last_disconnection"`
LastSeen []string `json:"last_seen"`
LastMiss string `json:"last_miss"`
}