smoldot 2.0.28 → 2.0.30
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/dist/cjs/internals/bytecode/wasm0.js +1 -1
- package/dist/cjs/internals/bytecode/wasm1.js +1 -1
- package/dist/cjs/internals/bytecode/wasm2.js +1 -1
- package/dist/cjs/internals/client.js +29 -17
- package/dist/cjs/public-types.d.ts +13 -0
- package/dist/mjs/internals/bytecode/wasm0.js +1 -1
- package/dist/mjs/internals/bytecode/wasm1.js +1 -1
- package/dist/mjs/internals/bytecode/wasm2.js +1 -1
- package/dist/mjs/internals/client.js +29 -17
- package/dist/mjs/public-types.d.ts +13 -0
- package/package.json +1 -1
|
@@ -327,25 +327,37 @@ function start(options, wasmModule, platformBindings) {
|
|
|
327
327
|
default: throw new Error("Internal error: unknown json_rpc_send error code: " + retVal);
|
|
328
328
|
}
|
|
329
329
|
},
|
|
330
|
+
jsonRpcResponses: {
|
|
331
|
+
next: () => __awaiter(this, void 0, void 0, function* () {
|
|
332
|
+
while (true) {
|
|
333
|
+
if (!state.chains.has(chainId))
|
|
334
|
+
return { done: true, value: undefined };
|
|
335
|
+
if (options.disableJsonRpc)
|
|
336
|
+
throw new public_types_js_1.JsonRpcDisabledError();
|
|
337
|
+
if (state.instance.status === "destroyed")
|
|
338
|
+
throw state.instance.error;
|
|
339
|
+
if (state.instance.status !== "ready")
|
|
340
|
+
throw new Error(); // Internal error. Never supposed to happen.
|
|
341
|
+
// Try to pop a message from the queue.
|
|
342
|
+
const message = state.instance.instance.peekJsonRpcResponse(chainId);
|
|
343
|
+
if (message)
|
|
344
|
+
return { done: false, value: message };
|
|
345
|
+
// If no message is available, wait for one to be.
|
|
346
|
+
yield new Promise((resolve) => {
|
|
347
|
+
state.chains.get(chainId).jsonRpcResponsesPromises.push(resolve);
|
|
348
|
+
});
|
|
349
|
+
}
|
|
350
|
+
}),
|
|
351
|
+
[Symbol.asyncIterator]() {
|
|
352
|
+
return this;
|
|
353
|
+
}
|
|
354
|
+
},
|
|
330
355
|
nextJsonRpcResponse: () => __awaiter(this, void 0, void 0, function* () {
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
if (options.disableJsonRpc)
|
|
335
|
-
return Promise.reject(new public_types_js_1.JsonRpcDisabledError());
|
|
336
|
-
if (state.instance.status === "destroyed")
|
|
337
|
-
throw state.instance.error;
|
|
338
|
-
if (state.instance.status !== "ready")
|
|
339
|
-
throw new Error(); // Internal error. Never supposed to happen.
|
|
340
|
-
// Try to pop a message from the queue.
|
|
341
|
-
const message = state.instance.instance.peekJsonRpcResponse(chainId);
|
|
342
|
-
if (message)
|
|
343
|
-
return message;
|
|
344
|
-
// If no message is available, wait for one to be.
|
|
345
|
-
yield new Promise((resolve) => {
|
|
346
|
-
state.chains.get(chainId).jsonRpcResponsesPromises.push(resolve);
|
|
347
|
-
});
|
|
356
|
+
const result = yield newChain.jsonRpcResponses.next();
|
|
357
|
+
if (result.done) {
|
|
358
|
+
throw new public_types_js_1.AlreadyDestroyedError();
|
|
348
359
|
}
|
|
360
|
+
return result.value;
|
|
349
361
|
}),
|
|
350
362
|
remove: () => {
|
|
351
363
|
if (state.instance.status === "destroyed")
|
|
@@ -137,6 +137,19 @@ export interface Chain {
|
|
|
137
137
|
* @throws {@link CrashError} If the background client has crashed.
|
|
138
138
|
*/
|
|
139
139
|
nextJsonRpcResponse(): Promise<string>;
|
|
140
|
+
/**
|
|
141
|
+
* JSON-RPC responses or notifications async iterable.
|
|
142
|
+
*
|
|
143
|
+
* Each chain contains a buffer of the responses waiting to be sent out. Iterating over this
|
|
144
|
+
* pulls one element from the buffer. If the iteration happen at a slower rate than
|
|
145
|
+
* responses are generated, then the buffer will eventually become full, at which point calling
|
|
146
|
+
* {@link Chain.sendJsonRpc} will throw an exception. The size of this buffer can be configured
|
|
147
|
+
* through {@link AddChainOptions.jsonRpcMaxPendingRequests}.
|
|
148
|
+
*
|
|
149
|
+
* @throws {@link JsonRpcDisabledError} If the JSON-RPC system was disabled in the options of the chain.
|
|
150
|
+
* @throws {@link CrashError} If the background client has crashed.
|
|
151
|
+
*/
|
|
152
|
+
readonly jsonRpcResponses: AsyncIterableIterator<string>;
|
|
140
153
|
/**
|
|
141
154
|
* Disconnects from the blockchain.
|
|
142
155
|
*
|