This repository has been archived by the owner on Aug 20, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
struct.go
273 lines (230 loc) · 6.61 KB
/
struct.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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
package service
import (
"bufio"
"os"
"sync"
"github.com/dedis/student_19_cruxIPFS/gentree"
"go.dedis.ch/onet/v3"
"go.dedis.ch/onet/v3/network"
"go.dedis.ch/onet/v3/simul/monitor"
)
// storageID reflects the data we're storing - we could store more
// than one structure.
var storageID = []byte("main")
// Service is our template-service
type Service struct {
// We need to embed the ServiceProcessor, so that incoming messages
// are correctly handled.
*onet.ServiceProcessor
storage *storage
Nodes gentree.LocalityNodes
LocalityTree *onet.Tree
Parents []*onet.TreeNode
GraphTree map[string][]gentree.GraphTree
BinaryTree map[string][]*onet.Tree
alive bool
Distances map[*gentree.LocalityNode]map[*gentree.LocalityNode]float64
PortMutex *sync.Mutex
W *bufio.Writer
File *os.File
metrics map[string]*monitor.TimeMeasure
metricsMutex sync.Mutex
BandwidthRx uint64
BandwidthTx uint64
NrMsgRx uint64
NrMsgTx uint64
NrProtocolsStarted uint64
OwnPings map[string]float64
DonePing bool
PingDistances map[string]map[string]float64
NrPingAnswers int
PingAnswerMtx sync.Mutex
PingMapMtx sync.Mutex
Name string // name of the service (node_2)
MyIP string // IP address
ConfigPath string // path to home config folder
MyIPFSPath string // path to ipfs config folder of that service
MinPort int // port range allocated to this node
MaxPort int
MyIPFS []IPFSInformation // own ipfs information
OtherIPFS map[string]IPFSInformation // node_x -> IP, ports etc.
OnetTree *onet.Tree
StartIPFSProt onet.ProtocolInstance
}
// FnService function that returns the service of that node
type FnService func() *Service
// storage is used to save our data.
type storage struct {
Count int
sync.Mutex
}
// ClusterInfo information about a given cluster
type ClusterInfo struct {
Leader string
Secret string
Size int
Instances []ClusterInstance
}
// ClusterInstance details of a cluster
type ClusterInstance struct {
HostName string
IP string
IPFSAPIAddr string
RestAPIPort int
IPFSProxyPort int
ClusterPort int
}
// IPFSInformation structure containing information about an IPFS instance
type IPFSInformation struct {
Name string
IP string
SwarmPort int
APIPort int
GatewayPort int
}
// InitRequest packet
type InitRequest struct {
Nodes []*gentree.LocalityNode
ServerIdentityToName map[*network.ServerIdentity]string
OnetTree *onet.Tree
Roster *onet.Roster
Cruxified bool
ComputePings bool
Mode string
}
// InitResponse packet
type InitResponse struct {
}
// ReqPings request packet for ping service
type ReqPings struct {
SenderName string
}
// ReplyPings reply packet for ping service
type ReplyPings struct {
Pings string
SenderName string
}
// NodeInfo contains ipfs and ipfs-cluster information for a given node
type NodeInfo struct {
IPFS IPFSInformation
Clusters []ClusterInfo
}
// StartIPFSProtocol structure
type StartIPFSProtocol struct {
*onet.TreeNodeInstance
announceChan chan announceWrapperStartIPFS
repliesChan chan []replyWrapperStartIPFS
Ready chan bool
GetService FnService
Nodes map[string]*NodeInfo
}
// StartIPFSAnnounce is used to pass a message to all children.
type StartIPFSAnnounce struct {
Message string
}
// announceWrapperWaitpeers just contains Announce and the data necessary to
// identify and process the message in onet.
type announceWrapperStartIPFS struct {
*onet.TreeNode
StartIPFSAnnounce
}
// StartIPFSReply returns true when ready.
type StartIPFSReply struct {
IPFS *IPFSInformation
Clusters *[]ClusterInfo
}
// replyWrapper just contains Reply and the data necessary to identify and
// process the message in onet.
type replyWrapperStartIPFS struct {
*onet.TreeNode
StartIPFSReply
}
// ClusterBootstrapProtocol structure
type ClusterBootstrapProtocol struct {
*onet.TreeNodeInstance
announceChan chan announceWrapperClusterBootstrap
repliesChan chan []replyWrapperClusterBootstrap
Ready chan bool
Info ClusterInfo
GetService FnService
}
// ClusterBootstrapAnnounce is used to pass a message to all children.
type ClusterBootstrapAnnounce struct {
SenderName string
Bootstrap string
Secret string
}
// announceWrapperClusterBootstrap just contains Announce and the data necessary
// to identify and process the message in onet.
type announceWrapperClusterBootstrap struct {
*onet.TreeNode
ClusterBootstrapAnnounce
}
// ClusterBootstrapReply returns true when ready.
type ClusterBootstrapReply struct {
Cluster *[]ClusterInstance
}
// replyWrapperClusterBootstrap just contains Reply and the data necessary to
// identify and process the message in onet.
type replyWrapperClusterBootstrap struct {
*onet.TreeNode
ClusterBootstrapReply
}
// StartARAProtocol structure
type StartARAProtocol struct {
*onet.TreeNodeInstance
announceChan chan announceWrapperStartARA
repliesChan chan []replyWrapperStartARA
Ready chan bool
Info ClusterInfo
GetService FnService
}
// StartARAAnnounce is used to pass a message to all children.
type StartARAAnnounce struct {
SenderName string
Bootstrap string
Secret string
}
// announceWrapperStartARA just contains Announce and the data necessary
// to identify and process the message in onet.
type announceWrapperStartARA struct {
*onet.TreeNode
StartARAAnnounce
}
// StartARAReply returns true when ready.
type StartARAReply struct {
Cluster *[]ClusterInstance
}
// replyWrapperStartARA just contains Reply and the data necessary to
// identify and process the message in onet.
type replyWrapperStartARA struct {
*onet.TreeNode
StartARAReply
}
// StartInstancesProtocol structure
type StartInstancesProtocol struct {
*onet.TreeNodeInstance
announceChan chan announceWrapperStartInstances
repliesChan chan []replyWrapperStartInstances
Ready chan bool
GetService FnService
Nodes map[string]*NodeInfo
}
// StartInstancesAnnounce is used to pass a message to all children.
type StartInstancesAnnounce struct{}
// announceWrapperStartInstances just contains Announce and the data necessary
// to identify and process the message in onet.
type announceWrapperStartInstances struct {
*onet.TreeNode
StartInstancesAnnounce
}
// StartInstancesReply returns true when ready.
type StartInstancesReply struct {
Node *NodeInfo
}
// replyWrapperStartInstances just contains Reply and the data necessary to
// identify and process the message in onet.
type replyWrapperStartInstances struct {
*onet.TreeNode
StartInstancesReply
}