@typeberry/lib 0.3.0 → 0.3.1-27dfdd9
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.cjs +8 -4
- package/index.d.ts +8 -4
- package/index.js +8 -4
- package/package.json +1 -1
package/index.cjs
CHANGED
|
@@ -7767,7 +7767,7 @@ const DEFAULT_CONFIG = "default";
|
|
|
7767
7767
|
const NODE_DEFAULTS = {
|
|
7768
7768
|
name: isBrowser() ? "browser" : os.hostname(),
|
|
7769
7769
|
config: [DEFAULT_CONFIG],
|
|
7770
|
-
pvm: PvmBackend.
|
|
7770
|
+
pvm: PvmBackend.Ananas,
|
|
7771
7771
|
};
|
|
7772
7772
|
/** Chain spec chooser. */
|
|
7773
7773
|
var KnownChainSpec;
|
|
@@ -11350,15 +11350,19 @@ class InMemorySerializedStates {
|
|
|
11350
11350
|
async updateAndSetState(header, state, update) {
|
|
11351
11351
|
const blake2b = this.blake2b;
|
|
11352
11352
|
const updatedValues = serializeStateUpdate(this.spec, blake2b, update);
|
|
11353
|
-
|
|
11353
|
+
// make sure to clone the leafs before writing, since the collection is re-used.
|
|
11354
|
+
const newLeafs = SortedSet.fromSortedArray(leafComparator, state.backend.leafs.array);
|
|
11355
|
+
const { values, leafs } = updateLeafs(newLeafs, blake2b, updatedValues);
|
|
11356
|
+
// make sure to reset the cache and re-create leafsdb lookup
|
|
11357
|
+
state.updateBackend(LeafDb.fromLeaves(leafs, state.backend.db));
|
|
11354
11358
|
// insert values to the db
|
|
11355
11359
|
// valuesdb can be shared between all states because it's just
|
|
11356
11360
|
// <valuehash> -> <value> mapping and existence is managed by trie leafs.
|
|
11357
11361
|
for (const val of values) {
|
|
11358
11362
|
this.valuesDb.set(val[0], val[1]);
|
|
11359
11363
|
}
|
|
11360
|
-
//
|
|
11361
|
-
this.db.set(header,
|
|
11364
|
+
// store new set of leaves
|
|
11365
|
+
this.db.set(header, leafs);
|
|
11362
11366
|
return Result$1.ok(OK);
|
|
11363
11367
|
}
|
|
11364
11368
|
getState(header) {
|
package/index.d.ts
CHANGED
|
@@ -8189,7 +8189,7 @@ declare const DEFAULT_CONFIG = "default";
|
|
|
8189
8189
|
declare const NODE_DEFAULTS = {
|
|
8190
8190
|
name: isBrowser() ? "browser" : os.hostname(),
|
|
8191
8191
|
config: [DEFAULT_CONFIG],
|
|
8192
|
-
pvm: PvmBackend.
|
|
8192
|
+
pvm: PvmBackend.Ananas,
|
|
8193
8193
|
};
|
|
8194
8194
|
|
|
8195
8195
|
/** Chain spec chooser. */
|
|
@@ -13131,7 +13131,11 @@ declare class InMemorySerializedStates implements StatesDb<SerializedState<LeafD
|
|
|
13131
13131
|
): Promise<Result$2<OK, StateUpdateError>> {
|
|
13132
13132
|
const blake2b = this.blake2b;
|
|
13133
13133
|
const updatedValues = serializeStateUpdate(this.spec, blake2b, update);
|
|
13134
|
-
|
|
13134
|
+
// make sure to clone the leafs before writing, since the collection is re-used.
|
|
13135
|
+
const newLeafs = SortedSet.fromSortedArray(leafComparator, state.backend.leafs.array);
|
|
13136
|
+
const { values, leafs } = updateLeafs(newLeafs, blake2b, updatedValues);
|
|
13137
|
+
// make sure to reset the cache and re-create leafsdb lookup
|
|
13138
|
+
state.updateBackend(LeafDb.fromLeaves(leafs, state.backend.db));
|
|
13135
13139
|
|
|
13136
13140
|
// insert values to the db
|
|
13137
13141
|
// valuesdb can be shared between all states because it's just
|
|
@@ -13140,8 +13144,8 @@ declare class InMemorySerializedStates implements StatesDb<SerializedState<LeafD
|
|
|
13140
13144
|
this.valuesDb.set(val[0], val[1]);
|
|
13141
13145
|
}
|
|
13142
13146
|
|
|
13143
|
-
//
|
|
13144
|
-
this.db.set(header,
|
|
13147
|
+
// store new set of leaves
|
|
13148
|
+
this.db.set(header, leafs);
|
|
13145
13149
|
|
|
13146
13150
|
return Result.ok(OK);
|
|
13147
13151
|
}
|
package/index.js
CHANGED
|
@@ -7764,7 +7764,7 @@ const DEFAULT_CONFIG = "default";
|
|
|
7764
7764
|
const NODE_DEFAULTS = {
|
|
7765
7765
|
name: isBrowser() ? "browser" : os.hostname(),
|
|
7766
7766
|
config: [DEFAULT_CONFIG],
|
|
7767
|
-
pvm: PvmBackend.
|
|
7767
|
+
pvm: PvmBackend.Ananas,
|
|
7768
7768
|
};
|
|
7769
7769
|
/** Chain spec chooser. */
|
|
7770
7770
|
var KnownChainSpec;
|
|
@@ -11347,15 +11347,19 @@ class InMemorySerializedStates {
|
|
|
11347
11347
|
async updateAndSetState(header, state, update) {
|
|
11348
11348
|
const blake2b = this.blake2b;
|
|
11349
11349
|
const updatedValues = serializeStateUpdate(this.spec, blake2b, update);
|
|
11350
|
-
|
|
11350
|
+
// make sure to clone the leafs before writing, since the collection is re-used.
|
|
11351
|
+
const newLeafs = SortedSet.fromSortedArray(leafComparator, state.backend.leafs.array);
|
|
11352
|
+
const { values, leafs } = updateLeafs(newLeafs, blake2b, updatedValues);
|
|
11353
|
+
// make sure to reset the cache and re-create leafsdb lookup
|
|
11354
|
+
state.updateBackend(LeafDb.fromLeaves(leafs, state.backend.db));
|
|
11351
11355
|
// insert values to the db
|
|
11352
11356
|
// valuesdb can be shared between all states because it's just
|
|
11353
11357
|
// <valuehash> -> <value> mapping and existence is managed by trie leafs.
|
|
11354
11358
|
for (const val of values) {
|
|
11355
11359
|
this.valuesDb.set(val[0], val[1]);
|
|
11356
11360
|
}
|
|
11357
|
-
//
|
|
11358
|
-
this.db.set(header,
|
|
11361
|
+
// store new set of leaves
|
|
11362
|
+
this.db.set(header, leafs);
|
|
11359
11363
|
return Result$1.ok(OK);
|
|
11360
11364
|
}
|
|
11361
11365
|
getState(header) {
|