smoldot 2.0.40 → 3.0.1-dev.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/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 +13 -1
- package/dist/cjs/internals/local-instance.d.ts +1 -1
- package/dist/cjs/internals/local-instance.js +2 -2
- package/dist/cjs/internals/remote-instance.js +3 -3
- package/dist/cjs/public-types.d.ts +8 -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 +13 -1
- package/dist/mjs/internals/local-instance.d.ts +1 -1
- package/dist/mjs/internals/local-instance.js +2 -2
- package/dist/mjs/internals/remote-instance.js +3 -3
- package/dist/mjs/public-types.d.ts +8 -0
- package/package.json +7 -5
|
@@ -298,11 +298,23 @@ function start(options, wasmModule, platformBindings) {
|
|
|
298
298
|
if (jsonRpcMaxSubscriptions > 0xffffffff) {
|
|
299
299
|
jsonRpcMaxSubscriptions = 0xffffffff;
|
|
300
300
|
}
|
|
301
|
+
// Sanitize `statementStore`.
|
|
302
|
+
let statementStoreMaxSeenStatements = 0;
|
|
303
|
+
if (options.statementStore !== undefined) {
|
|
304
|
+
statementStoreMaxSeenStatements = options.statementStore.maxSeenStatements === undefined ? 65536 : options.statementStore.maxSeenStatements;
|
|
305
|
+
statementStoreMaxSeenStatements = Math.floor(statementStoreMaxSeenStatements);
|
|
306
|
+
if (statementStoreMaxSeenStatements <= 0 || isNaN(statementStoreMaxSeenStatements)) {
|
|
307
|
+
throw new public_types_js_1.AddChainError("Invalid value for `statementStore.maxSeenStatements`");
|
|
308
|
+
}
|
|
309
|
+
if (statementStoreMaxSeenStatements > 0xffffffff) {
|
|
310
|
+
statementStoreMaxSeenStatements = 0xffffffff;
|
|
311
|
+
}
|
|
312
|
+
}
|
|
301
313
|
// Sanitize `databaseContent`.
|
|
302
314
|
if (options.databaseContent !== undefined && typeof options.databaseContent !== 'string')
|
|
303
315
|
throw new public_types_js_1.AddChainError("`databaseContent` is not a string");
|
|
304
316
|
const promise = new Promise((resolve) => state.addChainIdAllocations.push(resolve));
|
|
305
|
-
state.instance.instance.addChain(options.chainSpec, options.databaseContent || "", potentialRelayChainsIds, !!options.disableJsonRpc, jsonRpcMaxPendingRequests, jsonRpcMaxSubscriptions);
|
|
317
|
+
state.instance.instance.addChain(options.chainSpec, options.databaseContent || "", potentialRelayChainsIds, !!options.disableJsonRpc, jsonRpcMaxPendingRequests, jsonRpcMaxSubscriptions, statementStoreMaxSeenStatements);
|
|
306
318
|
const outcome = yield promise;
|
|
307
319
|
if (!outcome.success)
|
|
308
320
|
throw new public_types_js_1.AddChainError(outcome.error);
|
|
@@ -105,7 +105,7 @@ export interface Instance {
|
|
|
105
105
|
* indicate whether the initialization was actually successful. If `success` is `false`, then
|
|
106
106
|
* the `chainId` becomes unallocated.
|
|
107
107
|
*/
|
|
108
|
-
addChain: (chainSpec: string, databaseContent: string, potentialRelayChains: number[], disableJsonRpc: boolean, jsonRpcMaxPendingRequests: number, jsonRpcMaxSubscriptions: number) => void;
|
|
108
|
+
addChain: (chainSpec: string, databaseContent: string, potentialRelayChains: number[], disableJsonRpc: boolean, jsonRpcMaxPendingRequests: number, jsonRpcMaxSubscriptions: number, statementStoreMaxSeenStatements: number) => void;
|
|
109
109
|
removeChain: (chainId: number) => void;
|
|
110
110
|
/**
|
|
111
111
|
* Notifies the background executor that it should stop. Once it has effectively stopped,
|
|
@@ -386,7 +386,7 @@ function startLocalInstance(config, wasmModule, eventCallback) {
|
|
|
386
386
|
return null;
|
|
387
387
|
}
|
|
388
388
|
},
|
|
389
|
-
addChain: (chainSpec, databaseContent, potentialRelayChains, disableJsonRpc, jsonRpcMaxPendingRequests, jsonRpcMaxSubscriptions) => {
|
|
389
|
+
addChain: (chainSpec, databaseContent, potentialRelayChains, disableJsonRpc, jsonRpcMaxPendingRequests, jsonRpcMaxSubscriptions, statementStoreMaxSeenStatements) => {
|
|
390
390
|
if (!state.instance) {
|
|
391
391
|
eventCallback({ ty: "add-chain-id-allocated", chainId: 0 });
|
|
392
392
|
eventCallback({ ty: "add-chain-result", chainId: 0, success: false, error: "Smoldot has crashed" });
|
|
@@ -406,7 +406,7 @@ function startLocalInstance(config, wasmModule, eventCallback) {
|
|
|
406
406
|
state.bufferIndices[2] = potentialRelayChainsEncoded;
|
|
407
407
|
let chainId;
|
|
408
408
|
try {
|
|
409
|
-
chainId = state.instance.exports.add_chain(0, 1, disableJsonRpc ? 0 : jsonRpcMaxPendingRequests, jsonRpcMaxSubscriptions, 2);
|
|
409
|
+
chainId = state.instance.exports.add_chain(0, 1, disableJsonRpc ? 0 : jsonRpcMaxPendingRequests, jsonRpcMaxSubscriptions, 2, statementStoreMaxSeenStatements);
|
|
410
410
|
}
|
|
411
411
|
catch (_error) {
|
|
412
412
|
eventCallback({ ty: "add-chain-id-allocated", chainId: 0 });
|
|
@@ -147,9 +147,9 @@ function connectToInstanceServer(config) {
|
|
|
147
147
|
config.eventCallback(message);
|
|
148
148
|
};
|
|
149
149
|
return {
|
|
150
|
-
addChain(chainSpec, databaseContent, potentialRelayChains, disableJsonRpc, jsonRpcMaxPendingRequests, jsonRpcMaxSubscriptions) {
|
|
150
|
+
addChain(chainSpec, databaseContent, potentialRelayChains, disableJsonRpc, jsonRpcMaxPendingRequests, jsonRpcMaxSubscriptions, statementStoreMaxSeenStatements) {
|
|
151
151
|
return __awaiter(this, void 0, void 0, function* () {
|
|
152
|
-
const msg = { ty: "add-chain", chainSpec, databaseContent, potentialRelayChains, disableJsonRpc, jsonRpcMaxPendingRequests, jsonRpcMaxSubscriptions };
|
|
152
|
+
const msg = { ty: "add-chain", chainSpec, databaseContent, potentialRelayChains, disableJsonRpc, jsonRpcMaxPendingRequests, jsonRpcMaxSubscriptions, statementStoreMaxSeenStatements };
|
|
153
153
|
portToServer.postMessage(msg);
|
|
154
154
|
});
|
|
155
155
|
},
|
|
@@ -287,7 +287,7 @@ function startInstanceServer(config, initPortToClient) {
|
|
|
287
287
|
const message = messageEvent.data;
|
|
288
288
|
switch (message.ty) {
|
|
289
289
|
case "add-chain": {
|
|
290
|
-
state.instance.addChain(message.chainSpec, message.databaseContent, message.potentialRelayChains, message.disableJsonRpc, message.jsonRpcMaxPendingRequests, message.jsonRpcMaxSubscriptions);
|
|
290
|
+
state.instance.addChain(message.chainSpec, message.databaseContent, message.potentialRelayChains, message.disableJsonRpc, message.jsonRpcMaxPendingRequests, message.jsonRpcMaxSubscriptions, message.statementStoreMaxSeenStatements);
|
|
291
291
|
break;
|
|
292
292
|
}
|
|
293
293
|
case "remove-chain": {
|
|
@@ -398,4 +398,12 @@ export interface AddChainOptions {
|
|
|
398
398
|
* If this value is not set, it means that there is no maximum.
|
|
399
399
|
*/
|
|
400
400
|
jsonRpcMaxSubscriptions?: number;
|
|
401
|
+
/**
|
|
402
|
+
* If set, enables the Statement Store protocol on this chain.
|
|
403
|
+
*
|
|
404
|
+
* `maxSeenStatements` is the maximum number of seen statements to cache. Defaults to 65536.
|
|
405
|
+
*/
|
|
406
|
+
statementStore?: {
|
|
407
|
+
maxSeenStatements?: number;
|
|
408
|
+
};
|
|
401
409
|
}
|