@typeberry/jam 0.2.0-74f246e → 0.2.0-8017bfd
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/bootstrap-generator.mjs +166 -146
- package/bootstrap-generator.mjs.map +1 -1
- package/bootstrap-importer.mjs +256 -222
- package/bootstrap-importer.mjs.map +1 -1
- package/bootstrap-network.mjs +162 -143
- package/bootstrap-network.mjs.map +1 -1
- package/index.js +256 -222
- package/index.js.map +1 -1
- package/package.json +1 -1
package/bootstrap-network.mjs
CHANGED
|
@@ -31755,6 +31755,7 @@ function accumulationOutputComparator(a, b) {
|
|
|
31755
31755
|
|
|
31756
31756
|
;// CONCATENATED MODULE: ./packages/jam/block/gp-constants.ts
|
|
31757
31757
|
|
|
31758
|
+
|
|
31758
31759
|
/**
|
|
31759
31760
|
* This file lists all of the constants defined in the GrayPaper appendix.
|
|
31760
31761
|
*
|
|
@@ -31765,7 +31766,7 @@ function accumulationOutputComparator(a, b) {
|
|
|
31765
31766
|
* here are only temporarily for convenience. When we figure out better names
|
|
31766
31767
|
* and places for these this file will be eradicated.
|
|
31767
31768
|
*
|
|
31768
|
-
* https://graypaper.fluffylabs.dev/#/
|
|
31769
|
+
* https://graypaper.fluffylabs.dev/#/ab2cdbd/442300442300?v=0.7.2
|
|
31769
31770
|
*/
|
|
31770
31771
|
/** `G_I`: The gas allocated to invoke a work-package’s Is-Authorized logic. */
|
|
31771
31772
|
const G_I = 50_000_000;
|
|
@@ -31781,8 +31782,8 @@ const S = 1024;
|
|
|
31781
31782
|
const T = 128;
|
|
31782
31783
|
/** `W_A`: The maximum size of is-authorized code in octets. */
|
|
31783
31784
|
const W_A = 64_000;
|
|
31784
|
-
/** `W_B`: The maximum size of
|
|
31785
|
-
const W_B = 13_794_305;
|
|
31785
|
+
/** `W_B`: The maximum size of the concatenated variable-size blobs, extrinsics and imported segments of a work-package, in octets */
|
|
31786
|
+
const W_B = compatibility_Compatibility.isGreaterOrEqual(compatibility_GpVersion.V0_7_2) ? 13_791_360 : 13_794_305;
|
|
31786
31787
|
/** `W_C`: The maximum size of service code in octets. */
|
|
31787
31788
|
const W_C = 4_000_000;
|
|
31788
31789
|
/** `W_M`: The maximum number of imports in a work-package. */
|
|
@@ -32881,31 +32882,29 @@ var state_update_UpdatePreimageKind;
|
|
|
32881
32882
|
* 3. Update `LookupHistory` with given value.
|
|
32882
32883
|
*/
|
|
32883
32884
|
class UpdatePreimage {
|
|
32884
|
-
serviceId;
|
|
32885
32885
|
action;
|
|
32886
|
-
constructor(
|
|
32887
|
-
this.serviceId = serviceId;
|
|
32886
|
+
constructor(action) {
|
|
32888
32887
|
this.action = action;
|
|
32889
32888
|
}
|
|
32890
32889
|
/** A preimage is provided. We should update the lookuphistory and add the preimage to db. */
|
|
32891
|
-
static provide({
|
|
32892
|
-
return new UpdatePreimage(
|
|
32890
|
+
static provide({ preimage, slot }) {
|
|
32891
|
+
return new UpdatePreimage({
|
|
32893
32892
|
kind: state_update_UpdatePreimageKind.Provide,
|
|
32894
32893
|
preimage,
|
|
32895
32894
|
slot,
|
|
32896
32895
|
});
|
|
32897
32896
|
}
|
|
32898
32897
|
/** The preimage should be removed completely from the database. */
|
|
32899
|
-
static remove({
|
|
32900
|
-
return new UpdatePreimage(
|
|
32898
|
+
static remove({ hash, length }) {
|
|
32899
|
+
return new UpdatePreimage({
|
|
32901
32900
|
kind: state_update_UpdatePreimageKind.Remove,
|
|
32902
32901
|
hash,
|
|
32903
32902
|
length,
|
|
32904
32903
|
});
|
|
32905
32904
|
}
|
|
32906
32905
|
/** Update the lookup history of some preimage or add a new one (request). */
|
|
32907
|
-
static updateOrAdd({
|
|
32908
|
-
return new UpdatePreimage(
|
|
32906
|
+
static updateOrAdd({ lookupHistory }) {
|
|
32907
|
+
return new UpdatePreimage({
|
|
32909
32908
|
kind: state_update_UpdatePreimageKind.UpdateOrAdd,
|
|
32910
32909
|
item: lookupHistory,
|
|
32911
32910
|
});
|
|
@@ -32942,23 +32941,21 @@ var state_update_UpdateServiceKind;
|
|
|
32942
32941
|
UpdateServiceKind[UpdateServiceKind["Create"] = 1] = "Create";
|
|
32943
32942
|
})(state_update_UpdateServiceKind || (state_update_UpdateServiceKind = {}));
|
|
32944
32943
|
/**
|
|
32945
|
-
* Update service info
|
|
32944
|
+
* Update service info or create a new one.
|
|
32946
32945
|
*/
|
|
32947
32946
|
class UpdateService {
|
|
32948
|
-
serviceId;
|
|
32949
32947
|
action;
|
|
32950
|
-
constructor(
|
|
32951
|
-
this.serviceId = serviceId;
|
|
32948
|
+
constructor(action) {
|
|
32952
32949
|
this.action = action;
|
|
32953
32950
|
}
|
|
32954
|
-
static update({
|
|
32955
|
-
return new UpdateService(
|
|
32951
|
+
static update({ serviceInfo }) {
|
|
32952
|
+
return new UpdateService({
|
|
32956
32953
|
kind: state_update_UpdateServiceKind.Update,
|
|
32957
32954
|
account: serviceInfo,
|
|
32958
32955
|
});
|
|
32959
32956
|
}
|
|
32960
|
-
static create({
|
|
32961
|
-
return new UpdateService(
|
|
32957
|
+
static create({ serviceInfo, lookupHistory, }) {
|
|
32958
|
+
return new UpdateService({
|
|
32962
32959
|
kind: state_update_UpdateServiceKind.Create,
|
|
32963
32960
|
account: serviceInfo,
|
|
32964
32961
|
lookupHistory,
|
|
@@ -32979,17 +32976,15 @@ var state_update_UpdateStorageKind;
|
|
|
32979
32976
|
* Can either create/modify an entry or remove it.
|
|
32980
32977
|
*/
|
|
32981
32978
|
class UpdateStorage {
|
|
32982
|
-
serviceId;
|
|
32983
32979
|
action;
|
|
32984
|
-
constructor(
|
|
32985
|
-
this.serviceId = serviceId;
|
|
32980
|
+
constructor(action) {
|
|
32986
32981
|
this.action = action;
|
|
32987
32982
|
}
|
|
32988
|
-
static set({
|
|
32989
|
-
return new UpdateStorage(
|
|
32983
|
+
static set({ storage }) {
|
|
32984
|
+
return new UpdateStorage({ kind: state_update_UpdateStorageKind.Set, storage });
|
|
32990
32985
|
}
|
|
32991
|
-
static remove({
|
|
32992
|
-
return new UpdateStorage(
|
|
32986
|
+
static remove({ key }) {
|
|
32987
|
+
return new UpdateStorage({ kind: state_update_UpdateStorageKind.Remove, key });
|
|
32993
32988
|
}
|
|
32994
32989
|
get key() {
|
|
32995
32990
|
if (this.action.kind === state_update_UpdateStorageKind.Remove) {
|
|
@@ -33198,12 +33193,12 @@ class in_memory_state_InMemoryState extends WithDebug {
|
|
|
33198
33193
|
* Modify the state and apply a single state update.
|
|
33199
33194
|
*/
|
|
33200
33195
|
applyUpdate(update) {
|
|
33201
|
-
const {
|
|
33196
|
+
const { removed, created: _, updated, preimages, storage, ...rest } = update;
|
|
33202
33197
|
// just assign all other variables
|
|
33203
33198
|
Object.assign(this, rest);
|
|
33204
33199
|
// and update the services state
|
|
33205
33200
|
let result;
|
|
33206
|
-
result = this.updateServices(
|
|
33201
|
+
result = this.updateServices(updated);
|
|
33207
33202
|
if (result.isError) {
|
|
33208
33203
|
return result;
|
|
33209
33204
|
}
|
|
@@ -33215,7 +33210,7 @@ class in_memory_state_InMemoryState extends WithDebug {
|
|
|
33215
33210
|
if (result.isError) {
|
|
33216
33211
|
return result;
|
|
33217
33212
|
}
|
|
33218
|
-
this.removeServices(
|
|
33213
|
+
this.removeServices(removed);
|
|
33219
33214
|
return result_Result.ok(result_OK);
|
|
33220
33215
|
}
|
|
33221
33216
|
removeServices(servicesRemoved) {
|
|
@@ -33224,87 +33219,100 @@ class in_memory_state_InMemoryState extends WithDebug {
|
|
|
33224
33219
|
this.services.delete(serviceId);
|
|
33225
33220
|
}
|
|
33226
33221
|
}
|
|
33227
|
-
updateStorage(
|
|
33228
|
-
|
|
33229
|
-
|
|
33230
|
-
|
|
33231
|
-
|
|
33232
|
-
|
|
33233
|
-
|
|
33234
|
-
|
|
33235
|
-
|
|
33236
|
-
|
|
33237
|
-
|
|
33238
|
-
|
|
33239
|
-
|
|
33240
|
-
|
|
33222
|
+
updateStorage(storageUpdates) {
|
|
33223
|
+
if (storageUpdates === undefined) {
|
|
33224
|
+
return result_Result.ok(result_OK);
|
|
33225
|
+
}
|
|
33226
|
+
for (const [serviceId, updates] of storageUpdates.entries()) {
|
|
33227
|
+
for (const update of updates) {
|
|
33228
|
+
const { kind } = update.action;
|
|
33229
|
+
const service = this.services.get(serviceId);
|
|
33230
|
+
if (service === undefined) {
|
|
33231
|
+
return result_Result.error(in_memory_state_UpdateError.NoService, `Attempting to update storage of non-existing service: ${serviceId}`);
|
|
33232
|
+
}
|
|
33233
|
+
if (kind === state_update_UpdateStorageKind.Set) {
|
|
33234
|
+
const { key, value } = update.action.storage;
|
|
33235
|
+
service.data.storage.set(key.toString(), StorageItem.create({ key, value }));
|
|
33236
|
+
}
|
|
33237
|
+
else if (kind === state_update_UpdateStorageKind.Remove) {
|
|
33238
|
+
const { key } = update.action;
|
|
33239
|
+
debug_check `
|
|
33241
33240
|
${service.data.storage.has(key.toString())}
|
|
33242
|
-
Attempting to remove non-existing storage item at ${serviceId}: ${action.key}
|
|
33241
|
+
Attempting to remove non-existing storage item at ${serviceId}: ${update.action.key}
|
|
33243
33242
|
`;
|
|
33244
|
-
|
|
33245
|
-
|
|
33246
|
-
|
|
33247
|
-
|
|
33243
|
+
service.data.storage.delete(key.toString());
|
|
33244
|
+
}
|
|
33245
|
+
else {
|
|
33246
|
+
debug_assertNever(kind);
|
|
33247
|
+
}
|
|
33248
33248
|
}
|
|
33249
33249
|
}
|
|
33250
33250
|
return result_Result.ok(result_OK);
|
|
33251
33251
|
}
|
|
33252
|
-
updatePreimages(
|
|
33253
|
-
|
|
33252
|
+
updatePreimages(preimagesUpdates) {
|
|
33253
|
+
if (preimagesUpdates === undefined) {
|
|
33254
|
+
return result_Result.ok(result_OK);
|
|
33255
|
+
}
|
|
33256
|
+
for (const [serviceId, updates] of preimagesUpdates.entries()) {
|
|
33254
33257
|
const service = this.services.get(serviceId);
|
|
33255
33258
|
if (service === undefined) {
|
|
33256
33259
|
return result_Result.error(in_memory_state_UpdateError.NoService, `Attempting to update preimage of non-existing service: ${serviceId}`);
|
|
33257
33260
|
}
|
|
33258
|
-
const
|
|
33259
|
-
|
|
33260
|
-
|
|
33261
|
-
|
|
33262
|
-
|
|
33263
|
-
|
|
33264
|
-
service.data.preimages.set(preimage.hash, preimage);
|
|
33265
|
-
if (slot !== null) {
|
|
33266
|
-
const lookupHistory = service.data.lookupHistory.get(preimage.hash);
|
|
33267
|
-
const length = numbers_tryAsU32(preimage.blob.length);
|
|
33268
|
-
const lookup = new LookupHistoryItem(preimage.hash, length, service_tryAsLookupHistorySlots([slot]));
|
|
33269
|
-
if (lookupHistory === undefined) {
|
|
33270
|
-
// no lookup history for that preimage at all (edge case, should be requested)
|
|
33271
|
-
service.data.lookupHistory.set(preimage.hash, [lookup]);
|
|
33261
|
+
for (const update of updates) {
|
|
33262
|
+
const { kind } = update.action;
|
|
33263
|
+
if (kind === state_update_UpdatePreimageKind.Provide) {
|
|
33264
|
+
const { preimage, slot } = update.action;
|
|
33265
|
+
if (service.data.preimages.has(preimage.hash)) {
|
|
33266
|
+
return result_Result.error(in_memory_state_UpdateError.PreimageExists, `Overwriting existing preimage at ${serviceId}: ${preimage}`);
|
|
33272
33267
|
}
|
|
33273
|
-
|
|
33274
|
-
|
|
33275
|
-
const
|
|
33276
|
-
|
|
33268
|
+
service.data.preimages.set(preimage.hash, preimage);
|
|
33269
|
+
if (slot !== null) {
|
|
33270
|
+
const lookupHistory = service.data.lookupHistory.get(preimage.hash);
|
|
33271
|
+
const length = numbers_tryAsU32(preimage.blob.length);
|
|
33272
|
+
const lookup = new LookupHistoryItem(preimage.hash, length, service_tryAsLookupHistorySlots([slot]));
|
|
33273
|
+
if (lookupHistory === undefined) {
|
|
33274
|
+
// no lookup history for that preimage at all (edge case, should be requested)
|
|
33275
|
+
service.data.lookupHistory.set(preimage.hash, [lookup]);
|
|
33276
|
+
}
|
|
33277
|
+
else {
|
|
33278
|
+
// insert or replace exiting entry
|
|
33279
|
+
const index = lookupHistory.map((x) => x.length).indexOf(length);
|
|
33280
|
+
lookupHistory.splice(index, index === -1 ? 0 : 1, lookup);
|
|
33281
|
+
}
|
|
33277
33282
|
}
|
|
33278
33283
|
}
|
|
33279
|
-
|
|
33280
|
-
|
|
33281
|
-
|
|
33282
|
-
|
|
33283
|
-
|
|
33284
|
-
|
|
33285
|
-
|
|
33286
|
-
|
|
33284
|
+
else if (kind === state_update_UpdatePreimageKind.Remove) {
|
|
33285
|
+
const { hash, length } = update.action;
|
|
33286
|
+
service.data.preimages.delete(hash);
|
|
33287
|
+
const history = service.data.lookupHistory.get(hash) ?? [];
|
|
33288
|
+
const idx = history.map((x) => x.length).indexOf(length);
|
|
33289
|
+
if (idx !== -1) {
|
|
33290
|
+
history.splice(idx, 1);
|
|
33291
|
+
}
|
|
33292
|
+
}
|
|
33293
|
+
else if (kind === state_update_UpdatePreimageKind.UpdateOrAdd) {
|
|
33294
|
+
const { item } = update.action;
|
|
33295
|
+
const history = service.data.lookupHistory.get(item.hash) ?? [];
|
|
33296
|
+
const existingIdx = history.map((x) => x.length).indexOf(item.length);
|
|
33297
|
+
const removeCount = existingIdx === -1 ? 0 : 1;
|
|
33298
|
+
history.splice(existingIdx, removeCount, item);
|
|
33299
|
+
service.data.lookupHistory.set(item.hash, history);
|
|
33300
|
+
}
|
|
33301
|
+
else {
|
|
33302
|
+
debug_assertNever(kind);
|
|
33287
33303
|
}
|
|
33288
|
-
}
|
|
33289
|
-
else if (kind === state_update_UpdatePreimageKind.UpdateOrAdd) {
|
|
33290
|
-
const { item } = action;
|
|
33291
|
-
const history = service.data.lookupHistory.get(item.hash) ?? [];
|
|
33292
|
-
const existingIdx = history.map((x) => x.length).indexOf(item.length);
|
|
33293
|
-
const removeCount = existingIdx === -1 ? 0 : 1;
|
|
33294
|
-
history.splice(existingIdx, removeCount, item);
|
|
33295
|
-
service.data.lookupHistory.set(item.hash, history);
|
|
33296
|
-
}
|
|
33297
|
-
else {
|
|
33298
|
-
debug_assertNever(kind);
|
|
33299
33304
|
}
|
|
33300
33305
|
}
|
|
33301
33306
|
return result_Result.ok(result_OK);
|
|
33302
33307
|
}
|
|
33303
33308
|
updateServices(servicesUpdates) {
|
|
33304
|
-
|
|
33305
|
-
|
|
33309
|
+
if (servicesUpdates === undefined) {
|
|
33310
|
+
return result_Result.ok(result_OK);
|
|
33311
|
+
}
|
|
33312
|
+
for (const [serviceId, update] of servicesUpdates.entries()) {
|
|
33313
|
+
const { kind, account } = update.action;
|
|
33306
33314
|
if (kind === state_update_UpdateServiceKind.Create) {
|
|
33307
|
-
const { lookupHistory } = action;
|
|
33315
|
+
const { lookupHistory } = update.action;
|
|
33308
33316
|
if (this.services.has(serviceId)) {
|
|
33309
33317
|
return result_Result.error(in_memory_state_UpdateError.DuplicateService, `${serviceId} already exists!`);
|
|
33310
33318
|
}
|
|
@@ -34565,7 +34573,6 @@ function getKeccakTrieHasher(hasher) {
|
|
|
34565
34573
|
|
|
34566
34574
|
|
|
34567
34575
|
|
|
34568
|
-
|
|
34569
34576
|
/** What should be done with that key? */
|
|
34570
34577
|
var serialize_state_update_StateEntryUpdateAction;
|
|
34571
34578
|
(function (StateEntryUpdateAction) {
|
|
@@ -34581,76 +34588,88 @@ function* serialize_state_update_serializeStateUpdate(spec, blake2b, update) {
|
|
|
34581
34588
|
yield* serializeBasicKeys(spec, update);
|
|
34582
34589
|
const encode = (codec, val) => Encoder.encodeObject(codec, val, spec);
|
|
34583
34590
|
// then let's proceed with service updates
|
|
34584
|
-
yield* serializeServiceUpdates(update.
|
|
34591
|
+
yield* serializeServiceUpdates(update.updated, encode, blake2b);
|
|
34585
34592
|
yield* serializePreimages(update.preimages, encode, blake2b);
|
|
34586
34593
|
yield* serializeStorage(update.storage, blake2b);
|
|
34587
|
-
yield* serializeRemovedServices(update.
|
|
34594
|
+
yield* serializeRemovedServices(update.removed);
|
|
34588
34595
|
}
|
|
34589
34596
|
function* serializeRemovedServices(servicesRemoved) {
|
|
34590
|
-
|
|
34597
|
+
if (servicesRemoved === undefined) {
|
|
34598
|
+
return;
|
|
34599
|
+
}
|
|
34600
|
+
for (const serviceId of servicesRemoved) {
|
|
34591
34601
|
// TODO [ToDr] what about all data associated with a service?
|
|
34592
34602
|
const codec = serialize.serviceData(serviceId);
|
|
34593
34603
|
yield [serialize_state_update_StateEntryUpdateAction.Remove, codec.key, EMPTY_BLOB];
|
|
34594
34604
|
}
|
|
34595
34605
|
}
|
|
34596
|
-
function* serializeStorage(
|
|
34597
|
-
|
|
34598
|
-
|
|
34599
|
-
|
|
34600
|
-
|
|
34601
|
-
|
|
34602
|
-
|
|
34603
|
-
|
|
34604
|
-
|
|
34605
|
-
|
|
34606
|
-
|
|
34607
|
-
|
|
34608
|
-
|
|
34609
|
-
|
|
34606
|
+
function* serializeStorage(storageUpdates, blake2b) {
|
|
34607
|
+
if (storageUpdates === undefined) {
|
|
34608
|
+
return;
|
|
34609
|
+
}
|
|
34610
|
+
for (const [serviceId, updates] of storageUpdates.entries()) {
|
|
34611
|
+
for (const { action } of updates) {
|
|
34612
|
+
switch (action.kind) {
|
|
34613
|
+
case UpdateStorageKind.Set: {
|
|
34614
|
+
const key = action.storage.key;
|
|
34615
|
+
const codec = serialize.serviceStorage(blake2b, serviceId, key);
|
|
34616
|
+
yield [serialize_state_update_StateEntryUpdateAction.Insert, codec.key, action.storage.value];
|
|
34617
|
+
break;
|
|
34618
|
+
}
|
|
34619
|
+
case UpdateStorageKind.Remove: {
|
|
34620
|
+
const key = action.key;
|
|
34621
|
+
const codec = serialize.serviceStorage(blake2b, serviceId, key);
|
|
34622
|
+
yield [serialize_state_update_StateEntryUpdateAction.Remove, codec.key, EMPTY_BLOB];
|
|
34623
|
+
break;
|
|
34624
|
+
}
|
|
34610
34625
|
}
|
|
34611
|
-
default:
|
|
34612
|
-
assertNever(action);
|
|
34613
34626
|
}
|
|
34614
34627
|
}
|
|
34615
34628
|
}
|
|
34616
|
-
function* serializePreimages(
|
|
34617
|
-
|
|
34618
|
-
|
|
34619
|
-
|
|
34620
|
-
|
|
34621
|
-
|
|
34622
|
-
|
|
34623
|
-
|
|
34624
|
-
const
|
|
34625
|
-
|
|
34626
|
-
|
|
34627
|
-
|
|
34628
|
-
|
|
34629
|
-
|
|
34629
|
+
function* serializePreimages(preimagesUpdates, encode, blake2b) {
|
|
34630
|
+
if (preimagesUpdates === undefined) {
|
|
34631
|
+
return;
|
|
34632
|
+
}
|
|
34633
|
+
for (const [serviceId, updates] of preimagesUpdates.entries()) {
|
|
34634
|
+
for (const { action } of updates) {
|
|
34635
|
+
switch (action.kind) {
|
|
34636
|
+
case UpdatePreimageKind.Provide: {
|
|
34637
|
+
const { hash, blob } = action.preimage;
|
|
34638
|
+
const codec = serialize.servicePreimages(blake2b, serviceId, hash);
|
|
34639
|
+
yield [serialize_state_update_StateEntryUpdateAction.Insert, codec.key, blob];
|
|
34640
|
+
if (action.slot !== null) {
|
|
34641
|
+
const codec2 = serialize.serviceLookupHistory(blake2b, serviceId, hash, tryAsU32(blob.length));
|
|
34642
|
+
yield [
|
|
34643
|
+
serialize_state_update_StateEntryUpdateAction.Insert,
|
|
34644
|
+
codec2.key,
|
|
34645
|
+
encode(codec2.Codec, tryAsLookupHistorySlots([action.slot])),
|
|
34646
|
+
];
|
|
34647
|
+
}
|
|
34648
|
+
break;
|
|
34649
|
+
}
|
|
34650
|
+
case UpdatePreimageKind.UpdateOrAdd: {
|
|
34651
|
+
const { hash, length, slots } = action.item;
|
|
34652
|
+
const codec = serialize.serviceLookupHistory(blake2b, serviceId, hash, length);
|
|
34653
|
+
yield [serialize_state_update_StateEntryUpdateAction.Insert, codec.key, encode(codec.Codec, slots)];
|
|
34654
|
+
break;
|
|
34655
|
+
}
|
|
34656
|
+
case UpdatePreimageKind.Remove: {
|
|
34657
|
+
const { hash, length } = action;
|
|
34658
|
+
const codec = serialize.servicePreimages(blake2b, serviceId, hash);
|
|
34659
|
+
yield [serialize_state_update_StateEntryUpdateAction.Remove, codec.key, EMPTY_BLOB];
|
|
34660
|
+
const codec2 = serialize.serviceLookupHistory(blake2b, serviceId, hash, length);
|
|
34661
|
+
yield [serialize_state_update_StateEntryUpdateAction.Remove, codec2.key, EMPTY_BLOB];
|
|
34662
|
+
break;
|
|
34630
34663
|
}
|
|
34631
|
-
break;
|
|
34632
|
-
}
|
|
34633
|
-
case UpdatePreimageKind.UpdateOrAdd: {
|
|
34634
|
-
const { hash, length, slots } = action.item;
|
|
34635
|
-
const codec = serialize.serviceLookupHistory(blake2b, serviceId, hash, length);
|
|
34636
|
-
yield [serialize_state_update_StateEntryUpdateAction.Insert, codec.key, encode(codec.Codec, slots)];
|
|
34637
|
-
break;
|
|
34638
|
-
}
|
|
34639
|
-
case UpdatePreimageKind.Remove: {
|
|
34640
|
-
const { hash, length } = action;
|
|
34641
|
-
const codec = serialize.servicePreimages(blake2b, serviceId, hash);
|
|
34642
|
-
yield [serialize_state_update_StateEntryUpdateAction.Remove, codec.key, EMPTY_BLOB];
|
|
34643
|
-
const codec2 = serialize.serviceLookupHistory(blake2b, serviceId, hash, length);
|
|
34644
|
-
yield [serialize_state_update_StateEntryUpdateAction.Remove, codec2.key, EMPTY_BLOB];
|
|
34645
|
-
break;
|
|
34646
34664
|
}
|
|
34647
|
-
default:
|
|
34648
|
-
assertNever(action);
|
|
34649
34665
|
}
|
|
34650
34666
|
}
|
|
34651
34667
|
}
|
|
34652
34668
|
function* serializeServiceUpdates(servicesUpdates, encode, blake2b) {
|
|
34653
|
-
|
|
34669
|
+
if (servicesUpdates === undefined) {
|
|
34670
|
+
return;
|
|
34671
|
+
}
|
|
34672
|
+
for (const [serviceId, { action }] of servicesUpdates.entries()) {
|
|
34654
34673
|
// new service being created or updated
|
|
34655
34674
|
const codec = serialize.serviceData(serviceId);
|
|
34656
34675
|
yield [serialize_state_update_StateEntryUpdateAction.Insert, codec.key, encode(codec.Codec, action.account)];
|