@leofcoin/chain 1.7.8 → 1.7.9

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.
@@ -3925,6 +3925,7 @@ class Machine {
3925
3925
  totalBlocks: 0
3926
3926
  }
3927
3927
  };
3928
+ this.wantList = [];
3928
3929
  // @ts-ignore
3929
3930
  return this.#init(blocks);
3930
3931
  }
@@ -3980,8 +3981,14 @@ class Machine {
3980
3981
  }
3981
3982
  case 'ask': {
3982
3983
  if (data.question === 'contract' || data.question === 'transaction') {
3983
- const input = await peernet.get(data.input);
3984
- this.worker.postMessage({ id: data.id, input });
3984
+ try {
3985
+ const input = await peernet.get(data.input);
3986
+ this.worker.postMessage({ id: data.id, input });
3987
+ }
3988
+ catch (error) {
3989
+ console.error(error);
3990
+ this.wantList.push(data.input);
3991
+ }
3985
3992
  }
3986
3993
  }
3987
3994
  }
@@ -4342,6 +4349,12 @@ class State extends Contract {
4342
4349
  #totalSize;
4343
4350
  #machine;
4344
4351
  #loaded;
4352
+ /**
4353
+ * contains transactions we need before we can successfully load
4354
+ */
4355
+ get wantList() {
4356
+ return this.#machine.wantList;
4357
+ }
4345
4358
  get state() {
4346
4359
  return {
4347
4360
  sync: this.#syncState,
package/exports/chain.js CHANGED
@@ -292,6 +292,7 @@ class Machine {
292
292
  totalBlocks: 0
293
293
  }
294
294
  };
295
+ this.wantList = [];
295
296
  // @ts-ignore
296
297
  return this.#init(blocks);
297
298
  }
@@ -347,8 +348,14 @@ class Machine {
347
348
  }
348
349
  case 'ask': {
349
350
  if (data.question === 'contract' || data.question === 'transaction') {
350
- const input = await peernet.get(data.input);
351
- this.worker.postMessage({ id: data.id, input });
351
+ try {
352
+ const input = await peernet.get(data.input);
353
+ this.worker.postMessage({ id: data.id, input });
354
+ }
355
+ catch (error) {
356
+ console.error(error);
357
+ this.wantList.push(data.input);
358
+ }
352
359
  }
353
360
  }
354
361
  }
@@ -709,6 +716,12 @@ class State extends Contract {
709
716
  #totalSize;
710
717
  #machine;
711
718
  #loaded;
719
+ /**
720
+ * contains transactions we need before we can successfully load
721
+ */
722
+ get wantList() {
723
+ return this.#machine.wantList;
724
+ }
712
725
  get state() {
713
726
  return {
714
727
  sync: this.#syncState,
@@ -18,6 +18,7 @@ export default class Machine {
18
18
  totalBlocks: number;
19
19
  };
20
20
  };
21
+ wantList: string[];
21
22
  constructor(blocks: any);
22
23
  updateState(): Promise<void>;
23
24
  /**
@@ -12,7 +12,7 @@ export default class State extends Contract {
12
12
  /**
13
13
  * contains transactions we need before we can successfully load
14
14
  */
15
- wantList: string[];
15
+ get wantList(): string[];
16
16
  get state(): {
17
17
  sync: SyncState;
18
18
  chain: ChainState;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leofcoin/chain",
3
- "version": "1.7.8",
3
+ "version": "1.7.9",
4
4
  "description": "Official javascript implementation",
5
5
  "private": false,
6
6
  "exports": {