-
Notifications
You must be signed in to change notification settings - Fork 8
/
connections.go
52 lines (41 loc) · 1.58 KB
/
connections.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
package types
import (
"github.com/samber/mo"
)
// NodeType is the type of peer (farmer, full node, etc)
// https://github.com/Chia-Network/chia-blockchain/blob/main/chia/server/outbound_message.py#L12
type NodeType uint8
const (
// NodeTypeFullNode NodeType for full node
NodeTypeFullNode NodeType = 1
// NodeTypeHarvester NodeType for Harvester
NodeTypeHarvester NodeType = 2
// NodeTypeFarmer NodeType for Farmer
NodeTypeFarmer NodeType = 3
// NodeTypeTimelord NodeType for Timelord
NodeTypeTimelord NodeType = 4
// NodeTypeIntroducer NodeType for Introducer
NodeTypeIntroducer NodeType = 5
// NodeTypeWallet NodeType for Wallet
NodeTypeWallet NodeType = 6
// NodeTypeDataLayer Data Layer Node
NodeTypeDataLayer NodeType = 7
)
// Connection represents a single peer or internal connection
// https://github.com/Chia-Network/chia-blockchain/blob/main/chia/rpc/rpc_server.py#L119
type Connection struct {
Type NodeType `json:"type"`
LocalPort uint16 `json:"local_port"`
PeerHost string `json:"peer_host"` // Can be hostname as well as IP
PeerPort uint16 `json:"peer_port"`
PeerServerPort uint16 `json:"peer_server_port"`
NodeID Bytes32 `json:"node_id"`
CreationTime Timestamp `json:"creation_time"`
BytesRead uint64 `json:"bytes_read"`
BytesWritten uint64 `json:"bytes_written"`
LastMessageTime Timestamp `json:"last_message_time"`
// Full Node
PeakHash mo.Option[Bytes32] `json:"peak_hash"`
PeakHeight mo.Option[uint32] `json:"peak_height"`
PeakWeight mo.Option[Uint128] `json:"peak_weight"`
}