@typeberry/convert 0.11.0-829b7ea → 0.11.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/index.js +26 -4
- package/index.js.map +1 -1
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -11546,6 +11546,13 @@ var KnownChainSpec;
|
|
|
11546
11546
|
/** Full chain spec. */
|
|
11547
11547
|
KnownChainSpec["Full"] = "full";
|
|
11548
11548
|
})(KnownChainSpec || (KnownChainSpec = {}));
|
|
11549
|
+
/** Persistent regular-node database backend. */
|
|
11550
|
+
var RegularStateBackend;
|
|
11551
|
+
(function (RegularStateBackend) {
|
|
11552
|
+
/** @deprecated lmdb remains available as an explicit fallback, but fjall is the default backend. */
|
|
11553
|
+
RegularStateBackend["Lmdb"] = "lmdb";
|
|
11554
|
+
RegularStateBackend["Fjall"] = "fjall";
|
|
11555
|
+
})(RegularStateBackend || (RegularStateBackend = {}));
|
|
11549
11556
|
const knownChainSpecFromJson = json.fromString((input, ctx) => {
|
|
11550
11557
|
switch (input) {
|
|
11551
11558
|
case KnownChainSpec.Tiny:
|
|
@@ -11556,12 +11563,23 @@ const knownChainSpecFromJson = json.fromString((input, ctx) => {
|
|
|
11556
11563
|
throw Error(`unknown network flavor: ${input} at ${ctx}`);
|
|
11557
11564
|
}
|
|
11558
11565
|
});
|
|
11566
|
+
const regularStateBackendFromJson = json.fromString((input, ctx) => {
|
|
11567
|
+
switch (input) {
|
|
11568
|
+
case RegularStateBackend.Lmdb:
|
|
11569
|
+
return RegularStateBackend.Lmdb;
|
|
11570
|
+
case RegularStateBackend.Fjall:
|
|
11571
|
+
return RegularStateBackend.Fjall;
|
|
11572
|
+
default:
|
|
11573
|
+
throw Error(`unknown state backend: ${input} at ${ctx}`);
|
|
11574
|
+
}
|
|
11575
|
+
});
|
|
11559
11576
|
class NodeConfiguration {
|
|
11560
11577
|
$schema;
|
|
11561
11578
|
version;
|
|
11562
11579
|
flavor;
|
|
11563
11580
|
chainSpec;
|
|
11564
11581
|
databaseBasePath;
|
|
11582
|
+
stateBackend;
|
|
11565
11583
|
authorship;
|
|
11566
11584
|
rpc;
|
|
11567
11585
|
static fromJson = json.object({
|
|
@@ -11570,18 +11588,21 @@ class NodeConfiguration {
|
|
|
11570
11588
|
flavor: knownChainSpecFromJson,
|
|
11571
11589
|
chain_spec: JipChainSpec.fromJson,
|
|
11572
11590
|
database_base_path: json.optional("string"),
|
|
11591
|
+
state_backend: json.optional(regularStateBackendFromJson),
|
|
11573
11592
|
authorship: AuthorshipOptions.fromJson,
|
|
11574
11593
|
rpc: json.optional(RpcOptions.fromJson),
|
|
11575
11594
|
}, NodeConfiguration.new);
|
|
11576
|
-
static new({ $schema, version, flavor, chain_spec, database_base_path, authorship, rpc }) {
|
|
11595
|
+
static new({ $schema, version, flavor, chain_spec, database_base_path, state_backend, authorship, rpc, }) {
|
|
11577
11596
|
if (version !== 1) {
|
|
11578
11597
|
throw new Error("Only version=1 config is supported.");
|
|
11579
11598
|
}
|
|
11580
|
-
return new NodeConfiguration($schema, version, flavor, chain_spec, database_base_path ?? undefined, authorship, rpc ?? undefined);
|
|
11599
|
+
return new NodeConfiguration($schema, version, flavor, chain_spec, database_base_path ?? undefined, state_backend ?? RegularStateBackend.Fjall, authorship, rpc ?? undefined);
|
|
11581
11600
|
}
|
|
11582
11601
|
constructor($schema, version, flavor, chainSpec,
|
|
11583
11602
|
/** If database path is not provided, we load an in-memory db. */
|
|
11584
|
-
databaseBasePath,
|
|
11603
|
+
databaseBasePath,
|
|
11604
|
+
/** Persistent database backend used when `databaseBasePath` is set. */
|
|
11605
|
+
stateBackend, authorship,
|
|
11585
11606
|
/** Optional RPC server configuration. When present, an in-process RPC server is started. */
|
|
11586
11607
|
rpc) {
|
|
11587
11608
|
this.$schema = $schema;
|
|
@@ -11589,6 +11610,7 @@ class NodeConfiguration {
|
|
|
11589
11610
|
this.flavor = flavor;
|
|
11590
11611
|
this.chainSpec = chainSpec;
|
|
11591
11612
|
this.databaseBasePath = databaseBasePath;
|
|
11613
|
+
this.stateBackend = stateBackend;
|
|
11592
11614
|
this.authorship = authorship;
|
|
11593
11615
|
this.rpc = rpc;
|
|
11594
11616
|
}
|
|
@@ -16146,7 +16168,7 @@ function loadState(spec, blake2b, entries) {
|
|
|
16146
16168
|
* (incomplete in-memory view).
|
|
16147
16169
|
* - `SerializedState<LeafDb>`: Disk-backed trie storage-leaf nodes live on
|
|
16148
16170
|
* disk and load on demand; cheap to update (no data duplication) and re-compute
|
|
16149
|
-
* the `stateRoot`.
|
|
16171
|
+
* the `stateRoot`. Used in LMDB.
|
|
16150
16172
|
* - `SerializedState<StateEntries>`: serialized state represented as a simple in-memory
|
|
16151
16173
|
* hashmap of `key -> value` entries.
|
|
16152
16174
|
*/
|