@peerbit/shared-log-proxy 0.0.0-e209d2e
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +202 -0
- package/dist/src/auto.d.ts +18 -0
- package/dist/src/auto.d.ts.map +1 -0
- package/dist/src/auto.js +34 -0
- package/dist/src/auto.js.map +1 -0
- package/dist/src/client.d.ts +40 -0
- package/dist/src/client.d.ts.map +1 -0
- package/dist/src/client.js +457 -0
- package/dist/src/client.js.map +1 -0
- package/dist/src/host.d.ts +19 -0
- package/dist/src/host.d.ts.map +1 -0
- package/dist/src/host.js +384 -0
- package/dist/src/host.js.map +1 -0
- package/dist/src/index.d.ts +2 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +2 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/protocol.d.ts +223 -0
- package/dist/src/protocol.d.ts.map +1 -0
- package/dist/src/protocol.js +1017 -0
- package/dist/src/protocol.js.map +1 -0
- package/package.json +100 -0
- package/src/auto.ts +40 -0
- package/src/client.ts +639 -0
- package/src/host.ts +472 -0
- package/src/index.ts +1 -0
- package/src/protocol.ts +617 -0
package/src/protocol.ts
ADDED
|
@@ -0,0 +1,617 @@
|
|
|
1
|
+
import { field, fixedArray, option, variant, vec } from "@dao-xyz/borsh";
|
|
2
|
+
import { events, method, service } from "@dao-xyz/borsh-rpc";
|
|
3
|
+
import { PublicSignKey } from "@peerbit/crypto";
|
|
4
|
+
import { IdKey, Query, Sort } from "@peerbit/indexer-interface";
|
|
5
|
+
|
|
6
|
+
@variant("shared_log_bytes")
|
|
7
|
+
export class SharedLogBytes {
|
|
8
|
+
@field({ type: Uint8Array })
|
|
9
|
+
value: Uint8Array;
|
|
10
|
+
|
|
11
|
+
constructor(properties?: { value?: Uint8Array }) {
|
|
12
|
+
this.value = properties?.value ?? new Uint8Array();
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
@variant("shared_log_event")
|
|
17
|
+
export class SharedLogEvent {
|
|
18
|
+
@field({ type: PublicSignKey })
|
|
19
|
+
publicKey: PublicSignKey;
|
|
20
|
+
|
|
21
|
+
constructor(properties: { publicKey: PublicSignKey }) {
|
|
22
|
+
this.publicKey = properties.publicKey;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
@variant("open_shared_log")
|
|
27
|
+
export class OpenSharedLogRequest {
|
|
28
|
+
@field({ type: fixedArray("u8", 32) })
|
|
29
|
+
id: Uint8Array;
|
|
30
|
+
|
|
31
|
+
constructor(properties?: { id?: Uint8Array }) {
|
|
32
|
+
this.id = properties?.id ?? new Uint8Array(32);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
@variant("shared_log_replication_range")
|
|
37
|
+
export class SharedLogReplicationRange {
|
|
38
|
+
@field({ type: option(Uint8Array) })
|
|
39
|
+
id?: Uint8Array;
|
|
40
|
+
|
|
41
|
+
@field({ type: option("f64") })
|
|
42
|
+
factor?: number;
|
|
43
|
+
|
|
44
|
+
@field({ type: option("string") })
|
|
45
|
+
factorMode?: "all" | "right";
|
|
46
|
+
|
|
47
|
+
@field({ type: option("f64") })
|
|
48
|
+
offset?: number;
|
|
49
|
+
|
|
50
|
+
@field({ type: option("bool") })
|
|
51
|
+
normalized?: boolean;
|
|
52
|
+
|
|
53
|
+
@field({ type: option("bool") })
|
|
54
|
+
strict?: boolean;
|
|
55
|
+
|
|
56
|
+
constructor(properties?: {
|
|
57
|
+
id?: Uint8Array;
|
|
58
|
+
factor?: number;
|
|
59
|
+
factorMode?: "all" | "right";
|
|
60
|
+
offset?: number;
|
|
61
|
+
normalized?: boolean;
|
|
62
|
+
strict?: boolean;
|
|
63
|
+
}) {
|
|
64
|
+
this.id = properties?.id;
|
|
65
|
+
this.factor = properties?.factor;
|
|
66
|
+
this.factorMode = properties?.factorMode;
|
|
67
|
+
this.offset = properties?.offset;
|
|
68
|
+
this.normalized = properties?.normalized;
|
|
69
|
+
this.strict = properties?.strict;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
export abstract class SharedLogReplicateValue {}
|
|
74
|
+
|
|
75
|
+
@variant("shared_log_replicate_bool")
|
|
76
|
+
export class SharedLogReplicateBool extends SharedLogReplicateValue {
|
|
77
|
+
@field({ type: "bool" })
|
|
78
|
+
value: boolean;
|
|
79
|
+
|
|
80
|
+
constructor(value: boolean) {
|
|
81
|
+
super();
|
|
82
|
+
this.value = value;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
@variant("shared_log_replicate_factor")
|
|
87
|
+
export class SharedLogReplicateFactor extends SharedLogReplicateValue {
|
|
88
|
+
@field({ type: "f64" })
|
|
89
|
+
factor: number;
|
|
90
|
+
|
|
91
|
+
constructor(factor: number) {
|
|
92
|
+
super();
|
|
93
|
+
this.factor = factor;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
@variant("shared_log_replicate_fixed")
|
|
98
|
+
export class SharedLogReplicateFixed extends SharedLogReplicateValue {
|
|
99
|
+
@field({ type: SharedLogReplicationRange })
|
|
100
|
+
range: SharedLogReplicationRange;
|
|
101
|
+
|
|
102
|
+
constructor(range: SharedLogReplicationRange) {
|
|
103
|
+
super();
|
|
104
|
+
this.range = range;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
@variant("shared_log_replicate_fixed_list")
|
|
109
|
+
export class SharedLogReplicateFixedList extends SharedLogReplicateValue {
|
|
110
|
+
@field({ type: vec(SharedLogReplicationRange) })
|
|
111
|
+
ranges: SharedLogReplicationRange[];
|
|
112
|
+
|
|
113
|
+
constructor(ranges: SharedLogReplicationRange[]) {
|
|
114
|
+
super();
|
|
115
|
+
this.ranges = ranges;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
@variant("shared_log_replicate_request")
|
|
120
|
+
export class SharedLogReplicateRequest {
|
|
121
|
+
@field({ type: option(SharedLogReplicateValue) })
|
|
122
|
+
value?: SharedLogReplicateValue;
|
|
123
|
+
|
|
124
|
+
@field({ type: option("bool") })
|
|
125
|
+
reset?: boolean;
|
|
126
|
+
|
|
127
|
+
@field({ type: option("bool") })
|
|
128
|
+
checkDuplicates?: boolean;
|
|
129
|
+
|
|
130
|
+
@field({ type: option("bool") })
|
|
131
|
+
rebalance?: boolean;
|
|
132
|
+
|
|
133
|
+
@field({ type: option("bool") })
|
|
134
|
+
mergeSegments?: boolean;
|
|
135
|
+
|
|
136
|
+
constructor(properties?: {
|
|
137
|
+
value?: SharedLogReplicateValue;
|
|
138
|
+
reset?: boolean;
|
|
139
|
+
checkDuplicates?: boolean;
|
|
140
|
+
rebalance?: boolean;
|
|
141
|
+
mergeSegments?: boolean;
|
|
142
|
+
}) {
|
|
143
|
+
this.value = properties?.value;
|
|
144
|
+
this.reset = properties?.reset;
|
|
145
|
+
this.checkDuplicates = properties?.checkDuplicates;
|
|
146
|
+
this.rebalance = properties?.rebalance;
|
|
147
|
+
this.mergeSegments = properties?.mergeSegments;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
@variant("shared_log_unreplicate_request")
|
|
152
|
+
export class SharedLogUnreplicateRequest {
|
|
153
|
+
@field({ type: vec(Uint8Array) })
|
|
154
|
+
ids: Uint8Array[];
|
|
155
|
+
|
|
156
|
+
constructor(properties?: { ids?: Uint8Array[] }) {
|
|
157
|
+
this.ids = properties?.ids ?? [];
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
@variant("shared_log_replication_iterate_request")
|
|
162
|
+
export class SharedLogReplicationIterateRequest {
|
|
163
|
+
@field({ type: vec(Query) })
|
|
164
|
+
query: Query[];
|
|
165
|
+
|
|
166
|
+
@field({ type: vec(Sort) })
|
|
167
|
+
sort: Sort[];
|
|
168
|
+
|
|
169
|
+
constructor(properties?: { query?: Query[]; sort?: Sort[] }) {
|
|
170
|
+
this.query = properties?.query ?? [];
|
|
171
|
+
this.sort = properties?.sort ?? [];
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
@variant("shared_log_replication_count_request")
|
|
176
|
+
export class SharedLogReplicationCountRequest {
|
|
177
|
+
@field({ type: vec(Query) })
|
|
178
|
+
query: Query[];
|
|
179
|
+
|
|
180
|
+
constructor(properties?: { query?: Query[] }) {
|
|
181
|
+
this.query = properties?.query ?? [];
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
@variant("shared_log_replication_index_result")
|
|
186
|
+
export class SharedLogReplicationIndexResult {
|
|
187
|
+
@field({ type: IdKey })
|
|
188
|
+
id: IdKey;
|
|
189
|
+
|
|
190
|
+
@field({ type: SharedLogBytes })
|
|
191
|
+
value: SharedLogBytes;
|
|
192
|
+
|
|
193
|
+
constructor(properties: { id: IdKey; value: SharedLogBytes }) {
|
|
194
|
+
this.id = properties.id;
|
|
195
|
+
this.value = properties.value;
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
@variant("shared_log_entries_batch")
|
|
200
|
+
export class SharedLogEntriesBatch {
|
|
201
|
+
@field({ type: vec(SharedLogBytes) })
|
|
202
|
+
entries: SharedLogBytes[];
|
|
203
|
+
|
|
204
|
+
@field({ type: "bool" })
|
|
205
|
+
done: boolean;
|
|
206
|
+
|
|
207
|
+
constructor(properties: { entries?: SharedLogBytes[]; done?: boolean }) {
|
|
208
|
+
this.entries = properties.entries ?? [];
|
|
209
|
+
this.done = properties.done ?? false;
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
@variant("shared_log_replication_batch")
|
|
214
|
+
export class SharedLogReplicationBatch {
|
|
215
|
+
@field({ type: vec(SharedLogReplicationIndexResult) })
|
|
216
|
+
results: SharedLogReplicationIndexResult[];
|
|
217
|
+
|
|
218
|
+
@field({ type: "bool" })
|
|
219
|
+
done: boolean;
|
|
220
|
+
|
|
221
|
+
constructor(properties: {
|
|
222
|
+
results?: SharedLogReplicationIndexResult[];
|
|
223
|
+
done?: boolean;
|
|
224
|
+
}) {
|
|
225
|
+
this.results = properties.results ?? [];
|
|
226
|
+
this.done = properties.done ?? false;
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
@variant("shared_log_wait_for_replicator")
|
|
231
|
+
export class SharedLogWaitForReplicatorRequest {
|
|
232
|
+
@field({ type: PublicSignKey })
|
|
233
|
+
publicKey: PublicSignKey;
|
|
234
|
+
|
|
235
|
+
@field({ type: option("bool") })
|
|
236
|
+
eager?: boolean;
|
|
237
|
+
|
|
238
|
+
@field({ type: option("u32") })
|
|
239
|
+
timeoutMs?: number;
|
|
240
|
+
|
|
241
|
+
@field({ type: option("u32") })
|
|
242
|
+
roleAgeMs?: number;
|
|
243
|
+
|
|
244
|
+
@field({ type: option("string") })
|
|
245
|
+
requestId?: string;
|
|
246
|
+
|
|
247
|
+
constructor(properties: {
|
|
248
|
+
publicKey: PublicSignKey;
|
|
249
|
+
eager?: boolean;
|
|
250
|
+
timeoutMs?: number;
|
|
251
|
+
roleAgeMs?: number;
|
|
252
|
+
requestId?: string;
|
|
253
|
+
}) {
|
|
254
|
+
this.publicKey = properties.publicKey;
|
|
255
|
+
this.eager = properties.eager;
|
|
256
|
+
this.timeoutMs = properties.timeoutMs;
|
|
257
|
+
this.roleAgeMs = properties.roleAgeMs;
|
|
258
|
+
this.requestId = properties.requestId;
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
@variant("shared_log_wait_for_replicators")
|
|
263
|
+
export class SharedLogWaitForReplicatorsRequest {
|
|
264
|
+
@field({ type: option("u32") })
|
|
265
|
+
timeoutMs?: number;
|
|
266
|
+
|
|
267
|
+
@field({ type: option("u32") })
|
|
268
|
+
roleAgeMs?: number;
|
|
269
|
+
|
|
270
|
+
@field({ type: option("f64") })
|
|
271
|
+
coverageThreshold?: number;
|
|
272
|
+
|
|
273
|
+
@field({ type: option("bool") })
|
|
274
|
+
waitForNewPeers?: boolean;
|
|
275
|
+
|
|
276
|
+
@field({ type: option("string") })
|
|
277
|
+
requestId?: string;
|
|
278
|
+
|
|
279
|
+
constructor(properties?: {
|
|
280
|
+
timeoutMs?: number;
|
|
281
|
+
roleAgeMs?: number;
|
|
282
|
+
coverageThreshold?: number;
|
|
283
|
+
waitForNewPeers?: boolean;
|
|
284
|
+
requestId?: string;
|
|
285
|
+
}) {
|
|
286
|
+
this.timeoutMs = properties?.timeoutMs;
|
|
287
|
+
this.roleAgeMs = properties?.roleAgeMs;
|
|
288
|
+
this.coverageThreshold = properties?.coverageThreshold;
|
|
289
|
+
this.waitForNewPeers = properties?.waitForNewPeers;
|
|
290
|
+
this.requestId = properties?.requestId;
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
@variant("shared_log_coverage_request")
|
|
295
|
+
export class SharedLogCoverageRequest {
|
|
296
|
+
@field({ type: option("f64") })
|
|
297
|
+
start?: number;
|
|
298
|
+
|
|
299
|
+
@field({ type: option("f64") })
|
|
300
|
+
end?: number;
|
|
301
|
+
|
|
302
|
+
@field({ type: option("u32") })
|
|
303
|
+
roleAgeMs?: number;
|
|
304
|
+
|
|
305
|
+
constructor(properties?: {
|
|
306
|
+
start?: number;
|
|
307
|
+
end?: number;
|
|
308
|
+
roleAgeMs?: number;
|
|
309
|
+
}) {
|
|
310
|
+
this.start = properties?.start;
|
|
311
|
+
this.end = properties?.end;
|
|
312
|
+
this.roleAgeMs = properties?.roleAgeMs;
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
@service()
|
|
317
|
+
export class SharedLogEntriesIteratorService {
|
|
318
|
+
private _impl:
|
|
319
|
+
| {
|
|
320
|
+
next: (amount: number) => Promise<SharedLogEntriesBatch>;
|
|
321
|
+
pending: () => Promise<bigint | undefined>;
|
|
322
|
+
done: () => Promise<boolean>;
|
|
323
|
+
close: () => Promise<void>;
|
|
324
|
+
}
|
|
325
|
+
| undefined;
|
|
326
|
+
|
|
327
|
+
constructor(impl?: {
|
|
328
|
+
next: (amount: number) => Promise<SharedLogEntriesBatch>;
|
|
329
|
+
pending: () => Promise<bigint | undefined>;
|
|
330
|
+
done: () => Promise<boolean>;
|
|
331
|
+
close: () => Promise<void>;
|
|
332
|
+
}) {
|
|
333
|
+
this._impl = impl;
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
@method({ args: "u32", returns: SharedLogEntriesBatch })
|
|
337
|
+
async next(amount: number): Promise<SharedLogEntriesBatch> {
|
|
338
|
+
if (!this._impl)
|
|
339
|
+
throw new Error("SharedLogEntriesIteratorService not bound");
|
|
340
|
+
return this._impl.next(amount);
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
@method({ returns: option("u64") })
|
|
344
|
+
async pending(): Promise<bigint | undefined> {
|
|
345
|
+
if (!this._impl)
|
|
346
|
+
throw new Error("SharedLogEntriesIteratorService not bound");
|
|
347
|
+
return this._impl.pending();
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
@method({ returns: "bool" })
|
|
351
|
+
async done(): Promise<boolean> {
|
|
352
|
+
if (!this._impl)
|
|
353
|
+
throw new Error("SharedLogEntriesIteratorService not bound");
|
|
354
|
+
return this._impl.done();
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
@method({ returns: "void" })
|
|
358
|
+
async close(): Promise<void> {
|
|
359
|
+
if (!this._impl)
|
|
360
|
+
throw new Error("SharedLogEntriesIteratorService not bound");
|
|
361
|
+
return this._impl.close();
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
@service()
|
|
366
|
+
export class SharedLogReplicationIteratorService {
|
|
367
|
+
private _impl:
|
|
368
|
+
| {
|
|
369
|
+
next: (amount: number) => Promise<SharedLogReplicationBatch>;
|
|
370
|
+
pending: () => Promise<bigint | undefined>;
|
|
371
|
+
done: () => Promise<boolean>;
|
|
372
|
+
close: () => Promise<void>;
|
|
373
|
+
}
|
|
374
|
+
| undefined;
|
|
375
|
+
|
|
376
|
+
constructor(impl?: {
|
|
377
|
+
next: (amount: number) => Promise<SharedLogReplicationBatch>;
|
|
378
|
+
pending: () => Promise<bigint | undefined>;
|
|
379
|
+
done: () => Promise<boolean>;
|
|
380
|
+
close: () => Promise<void>;
|
|
381
|
+
}) {
|
|
382
|
+
this._impl = impl;
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
@method({ args: "u32", returns: SharedLogReplicationBatch })
|
|
386
|
+
async next(amount: number): Promise<SharedLogReplicationBatch> {
|
|
387
|
+
if (!this._impl)
|
|
388
|
+
throw new Error("SharedLogReplicationIteratorService not bound");
|
|
389
|
+
return this._impl.next(amount);
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
@method({ returns: option("u64") })
|
|
393
|
+
async pending(): Promise<bigint | undefined> {
|
|
394
|
+
if (!this._impl)
|
|
395
|
+
throw new Error("SharedLogReplicationIteratorService not bound");
|
|
396
|
+
return this._impl.pending();
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
@method({ returns: "bool" })
|
|
400
|
+
async done(): Promise<boolean> {
|
|
401
|
+
if (!this._impl)
|
|
402
|
+
throw new Error("SharedLogReplicationIteratorService not bound");
|
|
403
|
+
return this._impl.done();
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
@method({ returns: "void" })
|
|
407
|
+
async close(): Promise<void> {
|
|
408
|
+
if (!this._impl)
|
|
409
|
+
throw new Error("SharedLogReplicationIteratorService not bound");
|
|
410
|
+
return this._impl.close();
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
@service()
|
|
415
|
+
export class SharedLogService {
|
|
416
|
+
private _impl:
|
|
417
|
+
| {
|
|
418
|
+
logGet: (hash: string) => Promise<SharedLogBytes | undefined>;
|
|
419
|
+
logHas: (hash: string) => Promise<boolean>;
|
|
420
|
+
logToArray: () => Promise<SharedLogBytes[]>;
|
|
421
|
+
logGetHeads: () => Promise<SharedLogEntriesIteratorService>;
|
|
422
|
+
logLength: () => Promise<bigint>;
|
|
423
|
+
logBlockHas?: (hash: string) => Promise<boolean>;
|
|
424
|
+
replicationIterate: (
|
|
425
|
+
request: SharedLogReplicationIterateRequest,
|
|
426
|
+
) => Promise<SharedLogReplicationIteratorService>;
|
|
427
|
+
replicationCount: (
|
|
428
|
+
request: SharedLogReplicationCountRequest,
|
|
429
|
+
) => Promise<bigint>;
|
|
430
|
+
getReplicators: () => Promise<string[]>;
|
|
431
|
+
waitForReplicator: (
|
|
432
|
+
request: SharedLogWaitForReplicatorRequest,
|
|
433
|
+
) => Promise<void>;
|
|
434
|
+
waitForReplicators: (
|
|
435
|
+
request?: SharedLogWaitForReplicatorsRequest,
|
|
436
|
+
) => Promise<void>;
|
|
437
|
+
cancelWait?: (requestId: string) => Promise<void>;
|
|
438
|
+
replicate: (request?: SharedLogReplicateRequest) => Promise<void>;
|
|
439
|
+
unreplicate: (request?: SharedLogUnreplicateRequest) => Promise<void>;
|
|
440
|
+
calculateCoverage: (
|
|
441
|
+
request?: SharedLogCoverageRequest,
|
|
442
|
+
) => Promise<number>;
|
|
443
|
+
getMyReplicationSegments: () => Promise<SharedLogBytes[]>;
|
|
444
|
+
getAllReplicationSegments: () => Promise<SharedLogBytes[]>;
|
|
445
|
+
resolution: () => Promise<string>;
|
|
446
|
+
publicKey: () => Promise<PublicSignKey>;
|
|
447
|
+
close: () => Promise<void>;
|
|
448
|
+
}
|
|
449
|
+
| undefined;
|
|
450
|
+
|
|
451
|
+
@events(SharedLogEvent)
|
|
452
|
+
events = new EventTarget();
|
|
453
|
+
|
|
454
|
+
constructor(impl?: {
|
|
455
|
+
logGet: (hash: string) => Promise<SharedLogBytes | undefined>;
|
|
456
|
+
logHas: (hash: string) => Promise<boolean>;
|
|
457
|
+
logToArray: () => Promise<SharedLogBytes[]>;
|
|
458
|
+
logGetHeads: () => Promise<SharedLogEntriesIteratorService>;
|
|
459
|
+
logLength: () => Promise<bigint>;
|
|
460
|
+
logBlockHas?: (hash: string) => Promise<boolean>;
|
|
461
|
+
replicationIterate: (
|
|
462
|
+
request: SharedLogReplicationIterateRequest,
|
|
463
|
+
) => Promise<SharedLogReplicationIteratorService>;
|
|
464
|
+
replicationCount: (
|
|
465
|
+
request: SharedLogReplicationCountRequest,
|
|
466
|
+
) => Promise<bigint>;
|
|
467
|
+
getReplicators: () => Promise<string[]>;
|
|
468
|
+
waitForReplicator: (
|
|
469
|
+
request: SharedLogWaitForReplicatorRequest,
|
|
470
|
+
) => Promise<void>;
|
|
471
|
+
waitForReplicators: (
|
|
472
|
+
request?: SharedLogWaitForReplicatorsRequest,
|
|
473
|
+
) => Promise<void>;
|
|
474
|
+
cancelWait?: (requestId: string) => Promise<void>;
|
|
475
|
+
replicate: (request?: SharedLogReplicateRequest) => Promise<void>;
|
|
476
|
+
unreplicate: (request?: SharedLogUnreplicateRequest) => Promise<void>;
|
|
477
|
+
calculateCoverage: (request?: SharedLogCoverageRequest) => Promise<number>;
|
|
478
|
+
getMyReplicationSegments: () => Promise<SharedLogBytes[]>;
|
|
479
|
+
getAllReplicationSegments: () => Promise<SharedLogBytes[]>;
|
|
480
|
+
resolution: () => Promise<string>;
|
|
481
|
+
publicKey: () => Promise<PublicSignKey>;
|
|
482
|
+
close: () => Promise<void>;
|
|
483
|
+
}) {
|
|
484
|
+
this._impl = impl;
|
|
485
|
+
}
|
|
486
|
+
|
|
487
|
+
@method({ args: "string", returns: option(SharedLogBytes) })
|
|
488
|
+
async logGet(hash: string): Promise<SharedLogBytes | undefined> {
|
|
489
|
+
if (!this._impl) throw new Error("SharedLogService not bound");
|
|
490
|
+
return this._impl.logGet(hash);
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
@method({ args: "string", returns: "bool" })
|
|
494
|
+
async logHas(hash: string): Promise<boolean> {
|
|
495
|
+
if (!this._impl) throw new Error("SharedLogService not bound");
|
|
496
|
+
return this._impl.logHas(hash);
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
@method({ returns: vec(SharedLogBytes) })
|
|
500
|
+
async logToArray(): Promise<SharedLogBytes[]> {
|
|
501
|
+
if (!this._impl) throw new Error("SharedLogService not bound");
|
|
502
|
+
return this._impl.logToArray();
|
|
503
|
+
}
|
|
504
|
+
|
|
505
|
+
@method({ returns: SharedLogEntriesIteratorService })
|
|
506
|
+
async logGetHeads(): Promise<SharedLogEntriesIteratorService> {
|
|
507
|
+
if (!this._impl) throw new Error("SharedLogService not bound");
|
|
508
|
+
return this._impl.logGetHeads();
|
|
509
|
+
}
|
|
510
|
+
|
|
511
|
+
@method({ returns: "u64" })
|
|
512
|
+
async logLength(): Promise<bigint> {
|
|
513
|
+
if (!this._impl) throw new Error("SharedLogService not bound");
|
|
514
|
+
return this._impl.logLength();
|
|
515
|
+
}
|
|
516
|
+
|
|
517
|
+
@method({ args: "string", returns: "bool" })
|
|
518
|
+
async logBlockHas(hash: string): Promise<boolean> {
|
|
519
|
+
if (!this._impl?.logBlockHas) throw new Error("SharedLogService not bound");
|
|
520
|
+
return this._impl.logBlockHas(hash);
|
|
521
|
+
}
|
|
522
|
+
|
|
523
|
+
@method({
|
|
524
|
+
args: SharedLogReplicationIterateRequest,
|
|
525
|
+
returns: SharedLogReplicationIteratorService,
|
|
526
|
+
})
|
|
527
|
+
async replicationIterate(
|
|
528
|
+
request: SharedLogReplicationIterateRequest,
|
|
529
|
+
): Promise<SharedLogReplicationIteratorService> {
|
|
530
|
+
if (!this._impl) throw new Error("SharedLogService not bound");
|
|
531
|
+
return this._impl.replicationIterate(request);
|
|
532
|
+
}
|
|
533
|
+
|
|
534
|
+
@method({ args: SharedLogReplicationCountRequest, returns: "u64" })
|
|
535
|
+
async replicationCount(
|
|
536
|
+
request: SharedLogReplicationCountRequest,
|
|
537
|
+
): Promise<bigint> {
|
|
538
|
+
if (!this._impl) throw new Error("SharedLogService not bound");
|
|
539
|
+
return this._impl.replicationCount(request);
|
|
540
|
+
}
|
|
541
|
+
|
|
542
|
+
@method({ returns: vec("string") })
|
|
543
|
+
async getReplicators(): Promise<string[]> {
|
|
544
|
+
if (!this._impl) throw new Error("SharedLogService not bound");
|
|
545
|
+
return this._impl.getReplicators();
|
|
546
|
+
}
|
|
547
|
+
|
|
548
|
+
@method({ args: SharedLogWaitForReplicatorRequest, returns: "void" })
|
|
549
|
+
async waitForReplicator(
|
|
550
|
+
request: SharedLogWaitForReplicatorRequest,
|
|
551
|
+
): Promise<void> {
|
|
552
|
+
if (!this._impl) throw new Error("SharedLogService not bound");
|
|
553
|
+
return this._impl.waitForReplicator(request);
|
|
554
|
+
}
|
|
555
|
+
|
|
556
|
+
@method({ args: option(SharedLogWaitForReplicatorsRequest), returns: "void" })
|
|
557
|
+
async waitForReplicators(
|
|
558
|
+
request?: SharedLogWaitForReplicatorsRequest,
|
|
559
|
+
): Promise<void> {
|
|
560
|
+
if (!this._impl) throw new Error("SharedLogService not bound");
|
|
561
|
+
return this._impl.waitForReplicators(request);
|
|
562
|
+
}
|
|
563
|
+
|
|
564
|
+
@method({ args: "string", returns: "void" })
|
|
565
|
+
async cancelWait(requestId: string): Promise<void> {
|
|
566
|
+
if (!this._impl?.cancelWait) throw new Error("SharedLogService not bound");
|
|
567
|
+
return this._impl.cancelWait(requestId);
|
|
568
|
+
}
|
|
569
|
+
|
|
570
|
+
@method({ args: option(SharedLogReplicateRequest), returns: "void" })
|
|
571
|
+
async replicate(request?: SharedLogReplicateRequest): Promise<void> {
|
|
572
|
+
if (!this._impl) throw new Error("SharedLogService not bound");
|
|
573
|
+
return this._impl.replicate(request);
|
|
574
|
+
}
|
|
575
|
+
|
|
576
|
+
@method({ args: option(SharedLogUnreplicateRequest), returns: "void" })
|
|
577
|
+
async unreplicate(request?: SharedLogUnreplicateRequest): Promise<void> {
|
|
578
|
+
if (!this._impl) throw new Error("SharedLogService not bound");
|
|
579
|
+
return this._impl.unreplicate(request);
|
|
580
|
+
}
|
|
581
|
+
|
|
582
|
+
@method({ args: option(SharedLogCoverageRequest), returns: "f64" })
|
|
583
|
+
async calculateCoverage(request?: SharedLogCoverageRequest): Promise<number> {
|
|
584
|
+
if (!this._impl) throw new Error("SharedLogService not bound");
|
|
585
|
+
return this._impl.calculateCoverage(request);
|
|
586
|
+
}
|
|
587
|
+
|
|
588
|
+
@method({ returns: vec(SharedLogBytes) })
|
|
589
|
+
async getMyReplicationSegments(): Promise<SharedLogBytes[]> {
|
|
590
|
+
if (!this._impl) throw new Error("SharedLogService not bound");
|
|
591
|
+
return this._impl.getMyReplicationSegments();
|
|
592
|
+
}
|
|
593
|
+
|
|
594
|
+
@method({ returns: vec(SharedLogBytes) })
|
|
595
|
+
async getAllReplicationSegments(): Promise<SharedLogBytes[]> {
|
|
596
|
+
if (!this._impl) throw new Error("SharedLogService not bound");
|
|
597
|
+
return this._impl.getAllReplicationSegments();
|
|
598
|
+
}
|
|
599
|
+
|
|
600
|
+
@method({ returns: "string" })
|
|
601
|
+
async resolution(): Promise<string> {
|
|
602
|
+
if (!this._impl) throw new Error("SharedLogService not bound");
|
|
603
|
+
return this._impl.resolution();
|
|
604
|
+
}
|
|
605
|
+
|
|
606
|
+
@method({ returns: PublicSignKey })
|
|
607
|
+
async publicKey(): Promise<PublicSignKey> {
|
|
608
|
+
if (!this._impl) throw new Error("SharedLogService not bound");
|
|
609
|
+
return this._impl.publicKey();
|
|
610
|
+
}
|
|
611
|
+
|
|
612
|
+
@method({ returns: "void" })
|
|
613
|
+
async close(): Promise<void> {
|
|
614
|
+
if (!this._impl) throw new Error("SharedLogService not bound");
|
|
615
|
+
return this._impl.close();
|
|
616
|
+
}
|
|
617
|
+
}
|