lumina-node-wasm 0.3.1 → 0.5.0

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/README.md CHANGED
@@ -40,3 +40,8 @@ const client = await new NodeClient(channel.port2);
40
40
  await client.waitConnected();
41
41
  await client.requestHeadHeader();
42
42
  ```
43
+
44
+ ## Rust API
45
+
46
+ For comprehensive and fully typed interface documentation, see [lumina-node](https://docs.rs/lumina-node/latest/lumina_node/) and [celestia-types](https://docs.rs/celestia-types/latest/celestia_types/) documentation on docs.rs. You can see there the exact structure of more complex types, such as [`ExtendedHeader`](https://docs.rs/celestia-types/latest/celestia_types/struct.ExtendedHeader.html). JavaScript API's goal is to provide similar interface to Rust when possible, e.g. `NodeClient` mirrors [`Node`](https://docs.rs/lumina-node/latest/lumina_node/node/struct.Node.html).
47
+
@@ -26,6 +26,7 @@ export enum Network {
26
26
  Private = 3,
27
27
  }
28
28
  /**
29
+ * A range of blocks between `start` and `end` height, inclusive
29
30
  */
30
31
  export class BlockRange {
31
32
  /**
@@ -38,9 +39,11 @@ export class BlockRange {
38
39
  toString(): string;
39
40
  free(): void;
40
41
  /**
42
+ * Last block height in range
41
43
  */
42
44
  end: bigint;
43
45
  /**
46
+ * First block height in range
44
47
  */
45
48
  start: bigint;
46
49
  }
@@ -57,28 +60,36 @@ export class ConnectionCountersSnapshot {
57
60
  toString(): string;
58
61
  free(): void;
59
62
  /**
63
+ * The total number of connections, both pending and established.
60
64
  */
61
65
  num_connections: number;
62
66
  /**
67
+ * The number of outgoing connections being established.
63
68
  */
64
69
  num_established: number;
65
70
  /**
71
+ * The number of established incoming connections.
66
72
  */
67
73
  num_established_incoming: number;
68
74
  /**
75
+ * The number of established outgoing connections.
69
76
  */
70
77
  num_established_outgoing: number;
71
78
  /**
79
+ * The total number of pending connections, both incoming and outgoing.
72
80
  */
73
81
  num_pending: number;
74
82
  /**
83
+ * The total number of pending connections, both incoming and outgoing.
75
84
  */
76
85
  num_pending_incoming: number;
77
86
  /**
87
+ * The number of outgoing connections being established.
78
88
  */
79
89
  num_pending_outgoing: number;
80
90
  }
81
91
  /**
92
+ * Information about the connections
82
93
  */
83
94
  export class NetworkInfoSnapshot {
84
95
  /**
@@ -91,9 +102,11 @@ export class NetworkInfoSnapshot {
91
102
  toString(): string;
92
103
  free(): void;
93
104
  /**
105
+ * Gets counters for ongoing network connections.
94
106
  */
95
107
  connection_counters: ConnectionCountersSnapshot;
96
108
  /**
109
+ * The number of connected peers, i.e. peers with whom at least one established connection exists.
97
110
  */
98
111
  num_peers: number;
99
112
  }
@@ -129,6 +142,10 @@ export class NodeClient {
129
142
  */
130
143
  start(config: NodeConfig): Promise<void>;
131
144
  /**
145
+ * @returns {Promise<void>}
146
+ */
147
+ stop(): Promise<void>;
148
+ /**
132
149
  * Get node's local peer ID.
133
150
  * @returns {Promise<string>}
134
151
  */
@@ -275,12 +292,6 @@ export class NodeClient {
275
292
  */
276
293
  getSamplingMetadata(height: bigint): Promise<any>;
277
294
  /**
278
- * Requests SharedWorker running lumina to close. Any events received afterwards wont
279
- * be processed and new NodeClient needs to be created to restart a node.
280
- * @returns {Promise<void>}
281
- */
282
- close(): Promise<void>;
283
- /**
284
295
  * Returns a [`BroadcastChannel`] for events generated by [`Node`].
285
296
  * @returns {Promise<BroadcastChannel>}
286
297
  */
@@ -328,6 +339,7 @@ export class NodeWorker {
328
339
  run(): Promise<void>;
329
340
  }
330
341
  /**
342
+ * Statistics of the connected peers
331
343
  */
332
344
  export class PeerTrackerInfoSnapshot {
333
345
  /**
@@ -340,13 +352,16 @@ export class PeerTrackerInfoSnapshot {
340
352
  toString(): string;
341
353
  free(): void;
342
354
  /**
355
+ * Number of the connected peers.
343
356
  */
344
357
  num_connected_peers: bigint;
345
358
  /**
359
+ * Number of the connected trusted peers.
346
360
  */
347
361
  num_connected_trusted_peers: bigint;
348
362
  }
349
363
  /**
364
+ * Status of the synchronization.
350
365
  */
351
366
  export class SyncingInfoSnapshot {
352
367
  /**
@@ -359,124 +374,11 @@ export class SyncingInfoSnapshot {
359
374
  toString(): string;
360
375
  free(): void;
361
376
  /**
377
+ * Ranges of headers that are already synchronised
362
378
  */
363
379
  stored_headers: (BlockRange)[];
364
380
  /**
381
+ * Syncing target. The latest height seen in the network that was successfully verified.
365
382
  */
366
383
  subjective_head: bigint;
367
384
  }
368
-
369
- export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
370
-
371
- export interface InitOutput {
372
- readonly memory: WebAssembly.Memory;
373
- readonly setup_logging: () => void;
374
- readonly __wbg_nodeconfig_free: (a: number, b: number) => void;
375
- readonly __wbg_get_nodeconfig_network: (a: number) => number;
376
- readonly __wbg_set_nodeconfig_network: (a: number, b: number) => void;
377
- readonly __wbg_get_nodeconfig_bootnodes: (a: number, b: number) => void;
378
- readonly __wbg_set_nodeconfig_bootnodes: (a: number, b: number, c: number) => void;
379
- readonly __wbg_nodeclient_free: (a: number, b: number) => void;
380
- readonly nodeclient_new: (a: number) => number;
381
- readonly nodeclient_addConnectionToWorker: (a: number, b: number) => number;
382
- readonly nodeclient_isRunning: (a: number) => number;
383
- readonly nodeclient_start: (a: number, b: number) => number;
384
- readonly nodeclient_localPeerId: (a: number) => number;
385
- readonly nodeclient_peerTrackerInfo: (a: number) => number;
386
- readonly nodeclient_waitConnected: (a: number) => number;
387
- readonly nodeclient_waitConnectedTrusted: (a: number) => number;
388
- readonly nodeclient_networkInfo: (a: number) => number;
389
- readonly nodeclient_listeners: (a: number) => number;
390
- readonly nodeclient_connectedPeers: (a: number) => number;
391
- readonly nodeclient_setPeerTrust: (a: number, b: number, c: number, d: number) => number;
392
- readonly nodeclient_requestHeadHeader: (a: number) => number;
393
- readonly nodeclient_requestHeaderByHash: (a: number, b: number, c: number) => number;
394
- readonly nodeclient_requestHeaderByHeight: (a: number, b: number) => number;
395
- readonly nodeclient_requestVerifiedHeaders: (a: number, b: number, c: number) => number;
396
- readonly nodeclient_syncerInfo: (a: number) => number;
397
- readonly nodeclient_getNetworkHeadHeader: (a: number) => number;
398
- readonly nodeclient_getLocalHeadHeader: (a: number) => number;
399
- readonly nodeclient_getHeaderByHash: (a: number, b: number, c: number) => number;
400
- readonly nodeclient_getHeaderByHeight: (a: number, b: number) => number;
401
- readonly nodeclient_getHeaders: (a: number, b: number, c: number, d: number, e: number) => number;
402
- readonly nodeclient_getSamplingMetadata: (a: number, b: number) => number;
403
- readonly nodeclient_close: (a: number) => number;
404
- readonly nodeclient_eventsChannel: (a: number) => number;
405
- readonly nodeconfig_default: (a: number) => number;
406
- readonly __wbg_nodeworker_free: (a: number, b: number) => void;
407
- readonly nodeworker_new: (a: number) => number;
408
- readonly nodeworker_run: (a: number) => number;
409
- readonly __wbg_networkinfosnapshot_free: (a: number, b: number) => void;
410
- readonly __wbg_get_networkinfosnapshot_connection_counters: (a: number) => number;
411
- readonly __wbg_set_networkinfosnapshot_connection_counters: (a: number, b: number) => void;
412
- readonly __wbg_connectioncounterssnapshot_free: (a: number, b: number) => void;
413
- readonly __wbg_get_connectioncounterssnapshot_num_connections: (a: number) => number;
414
- readonly __wbg_set_connectioncounterssnapshot_num_connections: (a: number, b: number) => void;
415
- readonly __wbg_get_connectioncounterssnapshot_num_pending: (a: number) => number;
416
- readonly __wbg_set_connectioncounterssnapshot_num_pending: (a: number, b: number) => void;
417
- readonly __wbg_get_connectioncounterssnapshot_num_pending_incoming: (a: number) => number;
418
- readonly __wbg_set_connectioncounterssnapshot_num_pending_incoming: (a: number, b: number) => void;
419
- readonly __wbg_get_connectioncounterssnapshot_num_pending_outgoing: (a: number) => number;
420
- readonly __wbg_set_connectioncounterssnapshot_num_pending_outgoing: (a: number, b: number) => void;
421
- readonly __wbg_get_connectioncounterssnapshot_num_established: (a: number) => number;
422
- readonly __wbg_set_connectioncounterssnapshot_num_established: (a: number, b: number) => void;
423
- readonly __wbg_get_connectioncounterssnapshot_num_established_incoming: (a: number) => number;
424
- readonly __wbg_set_connectioncounterssnapshot_num_established_incoming: (a: number, b: number) => void;
425
- readonly __wbg_get_connectioncounterssnapshot_num_established_outgoing: (a: number) => number;
426
- readonly __wbg_set_connectioncounterssnapshot_num_established_outgoing: (a: number, b: number) => void;
427
- readonly __wbg_set_networkinfosnapshot_num_peers: (a: number, b: number) => void;
428
- readonly __wbg_get_networkinfosnapshot_num_peers: (a: number) => number;
429
- readonly __wbg_blockrange_free: (a: number, b: number) => void;
430
- readonly __wbg_get_blockrange_start: (a: number) => number;
431
- readonly __wbg_set_blockrange_start: (a: number, b: number) => void;
432
- readonly __wbg_get_blockrange_end: (a: number) => number;
433
- readonly __wbg_set_blockrange_end: (a: number, b: number) => void;
434
- readonly __wbg_syncinginfosnapshot_free: (a: number, b: number) => void;
435
- readonly __wbg_get_syncinginfosnapshot_stored_headers: (a: number, b: number) => void;
436
- readonly __wbg_set_syncinginfosnapshot_stored_headers: (a: number, b: number, c: number) => void;
437
- readonly __wbg_set_peertrackerinfosnapshot_num_connected_peers: (a: number, b: number) => void;
438
- readonly __wbg_set_peertrackerinfosnapshot_num_connected_trusted_peers: (a: number, b: number) => void;
439
- readonly __wbg_set_syncinginfosnapshot_subjective_head: (a: number, b: number) => void;
440
- readonly __wbg_get_peertrackerinfosnapshot_num_connected_peers: (a: number) => number;
441
- readonly __wbg_get_peertrackerinfosnapshot_num_connected_trusted_peers: (a: number) => number;
442
- readonly __wbg_get_syncinginfosnapshot_subjective_head: (a: number) => number;
443
- readonly __wbg_peertrackerinfosnapshot_free: (a: number, b: number) => void;
444
- readonly __wbindgen_malloc: (a: number, b: number) => number;
445
- readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
446
- readonly __wbindgen_export_2: WebAssembly.Table;
447
- readonly _dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h2f6a021db35c77b9: (a: number, b: number, c: number) => void;
448
- readonly _dyn_core__ops__function__Fn__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__hbb2cadc81740e52e: (a: number, b: number, c: number) => void;
449
- readonly _dyn_core__ops__function__FnMut_____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h551e5119637c385e: (a: number, b: number) => void;
450
- readonly _dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h62ad66d3e9f77ac4: (a: number, b: number, c: number) => void;
451
- readonly _dyn_core__ops__function__FnMut_____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h0a0047be2e37408e: (a: number, b: number) => void;
452
- readonly _dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h80386b419f109aff: (a: number, b: number, c: number) => void;
453
- readonly _dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h0ff40ee0b4df5b25: (a: number, b: number, c: number) => void;
454
- readonly _dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__hbfb1f6eb8d7aa58f: (a: number, b: number, c: number) => void;
455
- readonly _dyn_core__ops__function__FnMut_____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h9503509ad8c78ce2: (a: number, b: number) => void;
456
- readonly __wbindgen_add_to_stack_pointer: (a: number) => number;
457
- readonly __wbindgen_free: (a: number, b: number, c: number) => void;
458
- readonly __wbindgen_exn_store: (a: number) => void;
459
- readonly wasm_bindgen__convert__closures__invoke2_mut__h47e988f82b6e4529: (a: number, b: number, c: number, d: number) => void;
460
- readonly __wbindgen_start: () => void;
461
- }
462
-
463
- export type SyncInitInput = BufferSource | WebAssembly.Module;
464
- /**
465
- * Instantiates the given `module`, which can either be bytes or
466
- * a precompiled `WebAssembly.Module`.
467
- *
468
- * @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated.
469
- *
470
- * @returns {InitOutput}
471
- */
472
- export function initSync(module: { module: SyncInitInput } | SyncInitInput): InitOutput;
473
-
474
- /**
475
- * If `module_or_path` is {RequestInfo} or {URL}, makes a request and
476
- * for everything else, calls `WebAssembly.instantiate` directly.
477
- *
478
- * @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated.
479
- *
480
- * @returns {Promise<InitOutput>}
481
- */
482
- export default function __wbg_init (module_or_path?: { module_or_path: InitInput | Promise<InitInput> } | InitInput | Promise<InitInput>): Promise<InitOutput>;