-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathschema.proto
325 lines (266 loc) · 8.56 KB
/
schema.proto
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
syntax = "proto2";
package hyperspace;
import "hrpc.proto";
// General Structs
message Peer {
required bytes remotePublicKey = 1;
required string remoteAddress = 2;
required string type = 3;
}
// Hyperspace Methods
message HyperspaceStatusResponse {
required string apiVersion = 1;
optional bool holepunchable = 2;
optional string remoteAddress = 3;
optional string version = 4;
}
// Corestore Methods
message OpenRequest {
required uint32 id = 1;
optional bytes key = 2;
optional string name = 3;
optional bool weak = 4;
}
message OpenResponse {
required bytes key = 1;
required uint64 length = 2;
required uint64 byteLength = 3;
required bool writable = 4;
repeated Peer peers = 5;
optional bytes discoveryKey = 6;
}
// Corestore Events
message FeedEvent {
required bytes key = 1;
}
// Networking Methods
message OpenNetworkResponse {
required bytes publicKey = 1;
repeated Peer peers = 2;
}
message NetworkStatus {
required bytes discoveryKey = 1;
optional bool announce = 2;
optional bool lookup = 3;
optional bool remember = 4;
}
message ConfigureNetworkRequest {
required NetworkStatus configuration = 1;
optional bool flush = 2;
optional bytes copyFrom = 3;
optional bool overwrite = 4 [default = true];
}
message NetworkStatusRequest {
required bytes discoveryKey = 1;
}
message NetworkStatusResponse {
optional NetworkStatus status = 1;
}
message AllNetworkStatusesResponse {
repeated NetworkStatus statuses = 1;
}
message RegisterNetworkExtensionRequest {
required uint64 resourceId = 1;
required string name = 2;
}
message NetworkExtensionMessage {
required uint64 id = 1;
required uint64 resourceId = 2;
optional bytes remotePublicKey = 3;
required bytes data = 4;
}
// Hypercore Methods
message CloseRequest {
required uint32 id = 1;
}
message GetRequest {
required uint32 id = 1;
required uint64 seq = 2;
required uint64 resourceId = 3;
optional bool wait = 4 [default = true];
optional bool ifAvailable = 5 [default = true];
optional uint64 onWaitId = 6;
}
message GetResponse {
optional bytes block = 1;
}
message AppendRequest {
required uint32 id = 1;
repeated bytes blocks = 2;
}
message AppendResponse {
required uint64 length = 1;
required uint64 byteLength = 2;
required uint64 seq = 3;
}
message UpdateRequest {
required uint32 id = 1;
optional uint64 minLength = 2;
optional bool ifAvailable = 3 [default = true];
optional bool hash = 4 [default = true];
}
message SeekRequest {
required uint32 id = 1;
required uint64 byteOffset = 2;
optional uint64 start = 3;
optional uint64 end = 4;
optional bool wait = 5 [default = true];
optional bool ifAvailable = 6 [default = true];
}
message SeekResponse {
required uint64 seq = 1;
required uint64 blockOffset = 2;
}
message HasRequest {
required uint32 id = 1;
required uint64 seq = 2;
}
message HasResponse {
required bool has = 1;
}
message CancelRequest {
required uint64 id = 1;
required uint64 resourceId = 2;
}
message DownloadRequest {
required uint64 id = 1;
required uint64 resourceId = 2;
optional uint64 start = 3;
optional uint64 end = 4;
repeated uint64 blocks = 5;
optional bool linear = 6;
optional bool live = 7; // ie no end (end = -1 in the hypercore api)
}
message DownloadedRequest {
required uint64 id = 1;
optional uint64 start = 2;
optional uint64 end = 3;
}
message DownloadedResponse {
required uint64 bytes = 1;
}
message UndownloadRequest {
required uint64 id = 1;
required uint64 resourceId = 2;
}
message LockRequest {
required uint64 id = 1;
}
message WatchDownloadsRequest {
required uint64 id = 1;
}
message UnwatchDownloadsRequest {
required uint64 id = 1;
}
message WatchUploadsRequest {
required uint64 id = 1;
}
message UnwatchUploadsRequest {
required uint64 id = 1;
}
// Hypercore Events
message AppendEvent {
required uint64 id = 1;
required uint64 length = 2;
required uint64 byteLength = 3;
}
message PeerEvent {
required uint64 id = 1;
required Peer peer = 2;
}
message CloseEvent {
required uint64 id = 1;
}
message WaitEvent {
required uint64 id = 1;
required uint64 onWaitId = 2;
required uint64 seq = 3;
}
message DownloadEvent {
required uint64 id = 1;
required uint64 seq = 2;
optional uint64 byteLength = 3;
}
message UploadEvent {
required uint64 id = 1;
required uint64 seq = 2;
required uint64 byteLength = 3;
}
// Extension Methods
message RegisterExtensionRequest {
required uint64 id = 1;
required uint64 resourceId = 2;
required string name = 3;
}
message UnregisterExtensionRequest {
required uint64 id = 1;
required uint64 resourceId = 2;
}
message ExtensionMessage {
required uint64 id = 1;
required uint64 resourceId = 2;
optional bytes remotePublicKey = 3;
required bytes data = 4;
}
service Hyperspace {
option (hrpc.service) = 1;
// Methods
rpc Status (hrpc.Void) returns (HyperspaceStatusResponse) { option (hrpc.method) = 1; }
rpc Stop (hrpc.Void) returns (hrpc.Void) { option (hrpc.method) = 2; }
}
service Corestore {
option (hrpc.service) = 2;
// Methods
rpc Open (OpenRequest) returns (OpenResponse) { option (hrpc.method) = 1; }
// Events
rpc OnFeed (FeedEvent) returns (hrpc.Void) { option (hrpc.method) = 2; }
}
service Hypercore {
option (hrpc.service) = 3;
// Methods
rpc Get (GetRequest) returns (GetResponse) { option (hrpc.method) = 1; }
rpc Append (AppendRequest) returns (AppendResponse) { option (hrpc.method) = 2; }
rpc Update (UpdateRequest) returns (hrpc.Void) { option (hrpc.method) = 3; }
rpc Seek (SeekRequest) returns (SeekResponse) { option (hrpc.method) = 4; }
rpc Has (HasRequest) returns (HasResponse) { option (hrpc.method) = 5; }
rpc Cancel (CancelRequest) returns (hrpc.Void) { option (hrpc.method) = 6; }
rpc Download (DownloadRequest) returns (hrpc.Void) { option (hrpc.method) = 7; }
rpc Downloaded (DownloadedRequest) returns (DownloadedResponse) { option (hrpc.method) = 8; }
rpc Undownload (UndownloadRequest) returns (hrpc.Void) { option (hrpc.method) = 9; }
rpc Close (CloseRequest) returns (hrpc.Void) { option (hrpc.method) = 10; }
rpc RegisterExtension (RegisterExtensionRequest) returns (hrpc.Void) { option (hrpc.method) = 11; }
rpc UnregisterExtension (UnregisterExtensionRequest) returns (hrpc.Void) { option (hrpc.method) = 12; }
rpc SendExtension (ExtensionMessage) returns (hrpc.Void) { option (hrpc.method) = 13; }
rpc AcquireLock (LockRequest) returns (hrpc.Void) { option (hrpc.method) = 14; }
rpc ReleaseLock (LockRequest) returns (hrpc.Void) { option (hrpc.method) = 15; }
// Events
rpc OnAppend (AppendEvent) returns (hrpc.Void) { option (hrpc.method) = 16; }
rpc OnClose (CloseEvent) returns (hrpc.Void) { option (hrpc.method) = 17; }
rpc OnPeerOpen (PeerEvent) returns (hrpc.Void) { option (hrpc.method) = 18; }
rpc OnPeerRemove (PeerEvent) returns (hrpc.Void) { option (hrpc.method) = 19; }
rpc OnExtension (ExtensionMessage) returns (hrpc.Void) { option (hrpc.method) = 20; }
rpc OnWait (WaitEvent) returns (hrpc.Void) { option (hrpc.method) = 21; }
// Downloads
rpc WatchDownloads (WatchDownloadsRequest) returns (hrpc.Void) { option (hrpc.method) = 22; }
rpc UnwatchDownloads (UnwatchDownloadsRequest) returns (hrpc.Void) { option (hrpc.method) = 23; }
rpc OnDownload (DownloadEvent) returns (hrpc.Void) { option (hrpc.method) = 24; }
// Uploads
rpc WatchUploads (WatchUploadsRequest) returns (hrpc.Void) { option (hrpc.method) = 25; }
rpc UnwatchUploads (UnwatchUploadsRequest) returns (hrpc.Void) { option (hrpc.method) = 26; }
rpc OnUpload (UploadEvent) returns (hrpc.Void) { option (hrpc.method) = 27; }
}
service Network {
option (hrpc.service) = 4;
// Methods
rpc Open (hrpc.Void) returns (OpenNetworkResponse) { option (hrpc.method) = 1; }
rpc Configure (ConfigureNetworkRequest) returns (NetworkStatusResponse) { option (hrpc.method) = 2; }
rpc Status (NetworkStatusRequest) returns (NetworkStatusResponse) { option (hrpc.method) = 3; }
rpc AllStatuses (hrpc.Void) returns (AllNetworkStatusesResponse) { option (hrpc.method) = 4; }
rpc RegisterExtension (RegisterExtensionRequest) returns (hrpc.Void) { option (hrpc.method) = 5; }
rpc UnregisterExtension (UnregisterExtensionRequest) returns (hrpc.Void) { option (hrpc.method) = 6; }
rpc SendExtension (ExtensionMessage) returns (hrpc.Void) { option (hrpc.method) = 7; }
// Events
rpc OnPeerAdd (PeerEvent) returns (hrpc.Void) { option (hrpc.method) = 8; }
rpc OnPeerRemove (PeerEvent) returns (hrpc.Void) { option (hrpc.method) = 9; }
rpc OnExtension (ExtensionMessage) returns (hrpc.Void) { option (hrpc.method) = 10; }
}