-
Notifications
You must be signed in to change notification settings - Fork 39
/
types.go
325 lines (279 loc) · 8.97 KB
/
types.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
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
package rpc
import (
"github.com/stratosnet/sds/sds-msg/protos"
)
const (
GENERIC_ERR string = "-1"
SIGNATURE_FAILURE string = "-3"
WRONG_FILE_SIZE string = "-4"
TIME_OUT string = "-5"
FILE_REQ_FAILURE string = "-6"
WRONG_INPUT string = "-7"
WRONG_PP_ADDRESS string = "-8"
INTERNAL_DATA_FAILURE string = "-9"
INTERNAL_COMM_FAILURE string = "-10"
WRONG_FILE_INFO string = "-11"
WRONG_WALLET_ADDRESS string = "-12"
CONFLICT_WITH_ANOTHER_SESSION string = "-13"
SESSION_STOPPED string = "-14"
UPLOAD_DATA string = "1"
DOWNLOAD_OK string = "2"
DL_OK_ASK_INFO string = "3"
SHARED_DL_START string = "4"
SUCCESS string = "0"
)
// upload: request upload file
type ParamReqUploadFile struct {
FileName string `json:"filename"`
FileSize int `json:"filesize"`
FileHash string `json:"filehash"`
Signature Signature `json:"signature"`
DesiredTier uint32 `json:"desired_tier"`
AllowHigherTier bool `json:"allow_higher_tier"`
ReqTime int64 `json:"req_time"`
SequenceNumber string `json:"sequencenumber"`
}
// upload: upload file data
type ParamUploadData struct {
FileHash string `json:"filehash"`
Data string `json:"data"`
Signature Signature `json:"signature"`
ReqTime int64 `json:"req_time"`
SequenceNumber string `json:"sequencenumber"`
Stop bool `json:"stop,omitempty"`
}
// get current file status
type ParamGetFileStatus struct {
FileHash string `json:"filehash"`
Signature Signature `json:"signature"`
ReqTime int64 `json:"req_time"`
}
// download: request download file
type ParamReqDownloadFile struct {
FileHandle string `json:"filehandle"`
Signature Signature `json:"signature"`
ReqTime int64 `json:"req_time"`
}
// download: download file data
type ParamReqDownloadData struct {
FileHash string `json:"filehash"`
ReqId string `json:"reqid"`
SliceHash string `json:"slicehash"`
SliceNumber uint64 `json:"slicenumber"`
SliceSize uint64 `json:"slicesize"`
NetworkAddress string `json:"networkaddress"`
P2PAddress string `json:"p2pAddress"`
ReqTime int64 `json:"req_time"`
}
// download: download file data
type ParamDownloadData struct {
FileHash string `json:"filehash"`
ReqId string `json:"reqid"`
}
// download: downloaded file info
type ParamDownloadFileInfo struct {
FileHash string `json:"filehash"`
FileSize uint64 `json:"filesize"`
ReqId string `json:"reqid"`
}
// list: request file list
type ParamReqFileList struct {
Signature Signature `json:"signature"`
PageId uint64 `json:"page"`
ReqTime int64 `json:"req_time"`
}
// share: request share a file
type ParamReqShareFile struct {
FileHash string `json:"filehash"`
Signature Signature `json:"signature"`
Duration int64 `json:"duration"`
PrivateFlag bool `json:"bool"`
ReqTime int64 `json:"req_time"`
}
// share: request list shared files
type ParamReqListShared struct {
Signature Signature `json:"signature"`
PageId uint64 `json:"page"`
ReqTime int64 `json:"req_time"`
}
// share: request stop sharing a file
type ParamReqStopShare struct {
Signature Signature `json:"signature"`
ShareId string `json:"shareid"`
ReqTime int64 `json:"req_time"`
}
// share: request download a shared file
type ParamReqGetShared struct {
Signature Signature `json:"signature"`
ShareLink string `json:"sharelink"`
ReqTime int64 `json:"req_time"`
}
type FileInfo struct {
FileHash string `json:"filehash"`
FileSize uint64 `json:"filesize"`
FileName string `json:"filename"`
CreateTime uint64 `json:"createtime,omitempty"`
LinkTime int64 `json:"linktime,omitempty"`
LinkTimeExp int64 `json:"linktimeexp,omitempty"`
ShareId string `json:"shareid,omitempty"`
ShareLink string `json:"sharelink,omitempty"`
}
// share: request list shared files
type ParamReqDownloadShared struct {
FileHash string `json:"filehash"`
Signature Signature `json:"signature"`
ReqId string `json:"reqid"`
ReqTime int64 `json:"req_time"`
}
// ozone: get ozone
type ParamReqGetOzone struct {
WalletAddr string `json:"walletaddr"`
}
// result for all upload and download messages
type Result struct {
Return string `json:"return"`
ReqId string `json:"reqid,omitempty"`
OffsetStart *uint64 `json:"offsetstart,omitempty"`
OffsetEnd *uint64 `json:"offsetend,omitempty"`
FileHash string `json:"filehash,omitempty"`
FileName string `json:"filename,omitempty"`
FileData string `json:"filedata,omitempty"`
SequenceNumber string `json:"sequencenumber,omitempty"`
}
type FileStatusResult struct {
Return string `json:"return"`
Error string `json:"error,omitempty"`
FileUploadState protos.FileUploadState `json:"file_upload_state"`
UserHasFile bool `json:"user_has_file"`
Replicas uint32 `json:"replicas"`
}
type FileListResult struct {
Return string `json:"return"`
FileInfo []FileInfo `json:"fileinfo,omitempty"`
TotalNumber uint64 `json:"totalnumber,omitempty"`
PageId uint64 `json:"page,omitempty"`
}
type FileShareResult struct {
Return string `json:"return"`
ShareId string `json:"shareid,omitempty"`
ShareLink string `json:"sharelink,omitempty"`
FileInfo []FileInfo `json:"fileinfo,omitempty"`
TotalNumber uint64 `json:"totalnumber,omitempty"`
PageId uint64 `json:"page,omitempty"`
SequenceNumber string `json:"sequencynumber,omitempty"`
}
// result for getozone
type GetOzoneResult struct {
Return string `json:"return"`
Ozone string `json:"ozone,omitempty"`
SequenceNumber string `json:"sequencynumber,omitempty"`
}
// rp: request RegisterNewPP
type ParamReqRP struct {
//P2PAddr string `json:"p2paddr"`
Signature Signature `json:"signature"`
ReqTime int64 `json:"req_time"`
}
type RPResult struct {
Return string `json:"return"`
AlreadyPp bool `json:"alreadypp"`
}
// activate: request to activate pp node
type ParamReqActivate struct {
WalletAddr string `json:"walletaddr"`
Deposit string `json:"deposit"`
Fee string `json:"fee"`
Gas uint64 `json:"gas"`
}
type ActivateResult struct {
Return string `json:"return"`
ActivationState uint32 `json:"activationstate"`
}
// prepay: request to buy ozone using token
type ParamReqPrepay struct {
Signature Signature `json:"signature"`
PrepayAmount string `json:"prepayamount"`
Fee string `json:"fee"`
Gas uint64 `json:"gas"`
ReqTime int64 `json:"req_time"`
}
type PrepayResult struct {
Return string `json:"return"`
}
// startmining: request to startmining
type ParamReqStartMining struct {
WalletAddr string `json:"walletaddr"`
//P2PAddr string `json:"p2paddr"`
}
type StartMiningResult struct {
Return string `json:"return"`
}
// share: request to clear expired share links
type ParamReqClearExpiredShareLinks struct {
Signature Signature `json:"signature"`
ReqTime int64 `json:"req_time"`
}
type ClearExpiredShareLinksResult struct {
WalletAddr string `json:"walletaddr"`
Return string `json:"return"`
Deleted uint32 `json:"deleted"`
NewCount uint32 `json:"new_count"`
}
type ParamReqWithdraw struct {
Amount string `json:"amount"`
TargetAddress string `json:"target_address"`
Fee string `json:"fee"`
Gas uint64 `json:"gas"`
}
type WithdrawResult struct {
Return string `json:"return"`
}
type ParamReqSend struct {
Amount string `json:"amount"`
To string `json:"to"`
Fee string `json:"fee"`
Gas uint64 `json:"gas"`
}
type SendResult struct {
Return string `json:"return"`
}
type ParamReqSync struct {
TxHash string `json:"tx_hash"`
}
type SyncResult struct {
Return string `json:"return"`
}
type Signature struct {
Address string `json:"address"`
Pubkey string `json:"pubkey"`
Signature string `json:"signature"` // Hex-encoded
}
type ParamReqStatus struct {
WalletAddr string `json:"walletaddr"`
//P2PAddr string `json:"p2paddr"`
}
type StatusResult struct {
Return string `json:"return"`
Message string `json:"message"`
}
type ParamReqServiceStatus struct {
WalletAddr string `json:"walletaddr"`
//P2PAddr string `json:"p2paddr"`
}
type ServiceStatusResult struct {
Return string `json:"return"`
Message string `json:"message"`
}
type ParamReqUpdatePPInfo struct {
Moniker string `json:"moniker"`
Identity string `json:"identity"`
Website string `json:"website"`
SecurityContact string `json:"security_contact"`
Details string `json:"details"`
Fee string `json:"fee"`
Gas uint64 `json:"gas"`
}
type UpdatePPInfoResult struct {
Return string `json:"return"`
Message string `json:"message"`
}