@leofcoin/chain 1.3.1 → 1.3.3

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.
@@ -58565,8 +58565,8 @@ class Machine {
58565
58565
  #nonces = {}
58566
58566
  lastBlock = {index: 0, hash: '0x0', previousHash: '0x0'}
58567
58567
 
58568
- constructor() {
58569
- return this.#init()
58568
+ constructor(blocks) {
58569
+ return this.#init(blocks)
58570
58570
  }
58571
58571
 
58572
58572
  #createMessage(sender = peernet.selectedAccount) {
@@ -58603,7 +58603,7 @@ class Machine {
58603
58603
 
58604
58604
  }
58605
58605
 
58606
- async #init() {
58606
+ async #init(blocks) {
58607
58607
  return new Promise(async (resolve) => {
58608
58608
  pubsub.subscribe('machine.ready', () => {
58609
58609
  resolve(this);
@@ -58612,7 +58612,7 @@ class Machine {
58612
58612
  this.worker = await new EasyWorker((0,path_browserify.join)(chain_dirname, './workers/machine-worker.js'), {serialization: 'advanced', type:'module'});
58613
58613
  this.worker.onmessage(this.#onmessage.bind(this));
58614
58614
 
58615
- const blocks = await blockStore.values();
58615
+ // const blocks = await blockStore.values()
58616
58616
  const contracts = await Promise.all([
58617
58617
  contractStore.get(contractFactory$1),
58618
58618
  contractStore.get(nativeToken$1),
@@ -59052,7 +59052,7 @@ class Chain {
59052
59052
  const initialized = await contractStore.has(addresses.contractFactory);
59053
59053
  if (!initialized) await this.#setup();
59054
59054
 
59055
- this.#machine = await new Machine();
59055
+
59056
59056
  this.utils = { BigNumber: BigNumber, formatUnits: formatUnits, parseUnits: parseUnits };
59057
59057
 
59058
59058
  try {
@@ -59096,6 +59096,11 @@ class Chain {
59096
59096
 
59097
59097
  // load local blocks
59098
59098
  await this.resolveBlocks();
59099
+ this.#machine = await new Machine(this.#blocks);
59100
+ // for (const block of this.#blocks) {
59101
+ // block.loaded = true
59102
+ // }
59103
+ await this.#loadBlocks(this.#blocks);
59099
59104
  return this
59100
59105
  }
59101
59106
 
@@ -59122,8 +59127,8 @@ class Chain {
59122
59127
  debug(`synced ${blocksSynced} ${blocksSynced > 1 ? 'blocks' : 'block'}`);
59123
59128
 
59124
59129
  this.#blocks.length;
59125
- (this.#blocks.length) - blocksSynced;
59126
- await this.#loadBlocks(this.#blocks);
59130
+ const start = (this.#blocks.length) - blocksSynced;
59131
+ await this.#loadBlocks(this.blocks.slice(start));
59127
59132
  this.#lastBlock = this.#blocks[this.#blocks.length - 1];
59128
59133
  const message = await new BlockMessage(this.lastBlock);
59129
59134
  await blockStore.put(await message.hash, message.encoded);
@@ -59155,9 +59160,9 @@ async resolveBlock(hash) {
59155
59160
  if (!await peernet.has(hash, 'block')) await peernet.put(hash, block.encoded, 'block');
59156
59161
  const size = block.encoded.length || block.encoded.byteLength;
59157
59162
  block = {...block.decoded, hash};
59158
- if (this.#blocks[block.index]) throw `invalid block ${hash} @${block.index}`
59163
+ if (this.#blocks[block.index] && this.#blocks[block.index].hash !== block.hash) throw `invalid block ${hash} @${block.index}`
59159
59164
  this.#blocks[block.index] = block;
59160
- console.log(`loaded block: ${hash} @${block.index} ${formatBytes(size)}`);
59165
+ console.log(`resolved block: ${hash} @${block.index} ${formatBytes(size)}`);
59161
59166
  if (block.previousHash !== '0x0') {
59162
59167
  return this.resolveBlock(block.previousHash)
59163
59168
  }
@@ -59171,7 +59176,7 @@ async resolveBlock(hash) {
59171
59176
  if (hash && hash !== '0x0')
59172
59177
  await this.resolveBlock(hash);
59173
59178
  this.#lastBlock = this.#blocks[this.#blocks.length - 1];
59174
- await this.#loadBlocks(this.#blocks);
59179
+
59175
59180
  } catch (e) {
59176
59181
  await chainStore.put('lastBlock', new TextEncoder().encode('0x0'));
59177
59182
  return this.resolveBlocks()
@@ -59190,7 +59195,8 @@ async resolveBlock(hash) {
59190
59195
  console.log(e);
59191
59196
  }
59192
59197
  }
59193
- block.loaded = true;
59198
+ this.#blocks[block.index].loaded = true;
59199
+ console.log(`loaded block: ${block.hash} @${block.index}`);
59194
59200
  // let message = await peernet.get(block.hash, 'block')
59195
59201
 
59196
59202
  // const compressed = pako.deflate(message);
@@ -59242,8 +59248,6 @@ async resolveBlock(hash) {
59242
59248
  // transaction = new TransactionMessage(transaction)
59243
59249
  // return transaction
59244
59250
  // }
59245
-
59246
- console.log(blockMessage);
59247
59251
  await Promise.all(blockMessage.decoded.transactions
59248
59252
  .map(async transaction => transactionPoolStore.delete(await transaction.hash)));
59249
59253
  const hash = await blockMessage.hash;
@@ -436,7 +436,7 @@ class Peer {
436
436
  this.#connection.ondatachannel = (message) => {
437
437
  message.channel.onopen = () => {
438
438
  this.#connected = true
439
- debug(`peer:connected ${this}`)
439
+ // debug(`peer:connected ${this}`)
440
440
  pubsub.publish('peer:connected', this)
441
441
  }
442
442
  message.channel.onclose = () => this.close.bind(this)
@@ -473,7 +473,7 @@ class Peer {
473
473
  }
474
474
 
475
475
  _handleMessage(peerId, message) {
476
- debug(`incoming message from ${peerId}`)
476
+ // debug(`incoming message from ${peerId}`)
477
477
 
478
478
  message = JSON.parse(new TextDecoder().decode(message.data))
479
479
  // allow sharding (multiple peers share data)
@@ -515,7 +515,7 @@ class Peer {
515
515
 
516
516
 
517
517
  if (message.candidate) {
518
- debug(`incoming candidate ${this.#channelName}`)
518
+ // debug(`incoming candidate ${this.#channelName}`)
519
519
  // debug(message.candidate.candidate)
520
520
  this.remoteAddress = message.candidate.address
521
521
  this.remotePort = message.candidate.port
@@ -526,14 +526,14 @@ class Peer {
526
526
  try {
527
527
  if (message.sdp) {
528
528
  if (message.sdp.type === 'offer') {
529
- debug(`incoming offer ${this.#channelName}`)
529
+ // debug(`incoming offer ${this.#channelName}`)
530
530
  await this.#connection.setRemoteDescription(new wrtc.RTCSessionDescription(message.sdp))
531
531
  const answer = await this.#connection.createAnswer();
532
532
  await this.#connection.setLocalDescription(answer)
533
533
  this._sendMessage({'sdp': this.#connection.localDescription})
534
534
  }
535
535
  if (message.sdp.type === 'answer') {
536
- debug(`incoming answer ${this.#channelName}`)
536
+ // debug(`incoming answer ${this.#channelName}`)
537
537
  await this.#connection.setRemoteDescription(new wrtc.RTCSessionDescription(message.sdp))
538
538
  }
539
539
  }
@@ -543,7 +543,7 @@ class Peer {
543
543
  }
544
544
 
545
545
  close() {
546
- debug(`closing ${this.peerId}`)
546
+ // debug(`closing ${this.peerId}`)
547
547
  this.#connected = false
548
548
  this.#channel?.close()
549
549
  this.#connection?.close()
@@ -578,11 +578,10 @@ class Client {
578
578
  this.starJoined = this.starJoined.bind(this)
579
579
  this.networkVersion = networkVersion
580
580
 
581
- this._init(network, stars)
581
+ this._init(stars)
582
582
  }
583
583
 
584
- async _init(network, stars = [], networkVersion) {
585
- this.network = network
584
+ async _init(stars = []) {
586
585
  this.starsConfig = stars
587
586
  // reconnectJob()
588
587
 
@@ -11723,6 +11723,11 @@ var __webpack_exports__ = {};
11723
11723
  // This entry need to be wrapped in an IIFE because it need to be isolated against other modules in the chunk.
11724
11724
  !function() {
11725
11725
 
11726
+ // EXPORTS
11727
+ __webpack_require__.d(__webpack_exports__, {
11728
+ "T": function() { return /* binding */ unique; }
11729
+ });
11730
+
11726
11731
  ;// CONCATENATED MODULE: ./node_modules/@vandeurenglenn/base-x/src/base-x.js
11727
11732
  // base-x encoding / decoding
11728
11733
  // Copyright (c) 2018 base-x contributors
@@ -13722,6 +13727,9 @@ globalThis.BigNumber = BigNumber;
13722
13727
  globalThis.peernet = globalThis.peernet || {};
13723
13728
  globalThis.contracts = {};
13724
13729
 
13730
+ const unique = arr => arr.filter((el, pos, arr) => {
13731
+ return arr.indexOf(el) == pos;
13732
+ });
13725
13733
 
13726
13734
  const get = (contract, method, params) => {
13727
13735
  let result;
@@ -13819,16 +13827,23 @@ const _init = async ({ contracts, blocks, peerid })=> {
13819
13827
 
13820
13828
  if (blocks?.length > 0) {
13821
13829
  const _worker = await new EasyWorker('./block-worker.js', {serialization: 'advanced', type: 'module' });
13822
- blocks = await _worker.once(blocks);
13830
+ blocks = await _worker.once([blocks[blocks.length - 1]]);
13823
13831
 
13824
- for (const block of blocks) {
13825
- await Promise.all(block.decoded.transactions.map(async message => {
13826
- const {from, to, method, params} = message;
13827
- globalThis.msg = createMessage(from);
13828
-
13829
- await execute(to, method, params);
13830
- }));
13831
- }
13832
+ // blocks = unique(globalThis.blocks ? globalThis : [], blocks)
13833
+ // for (let i = 0; i < blocks.length; i++) {
13834
+
13835
+ // }
13836
+ // for (const block of blocks) {
13837
+ // await Promise.all(block.decoded.transactions.map(async message => {
13838
+ // if (!block.loaded) {
13839
+ // const {from, to, method, params} = message;
13840
+ // globalThis.msg = createMessage(from);
13841
+
13842
+ // await execute(to, method, params);
13843
+ // block.loaded = true
13844
+ // }
13845
+ // }));
13846
+ // }
13832
13847
 
13833
13848
  if (blocks.length > 0) {
13834
13849
  lastBlock = blocks[blocks.length - 1].decoded;
@@ -13839,15 +13854,15 @@ const _init = async ({ contracts, blocks, peerid })=> {
13839
13854
  hash: await lastBlock.hash
13840
13855
  };
13841
13856
  }
13857
+ globalThis.blocks = blocks;
13842
13858
  }
13843
13859
 
13844
13860
 
13845
13861
 
13846
13862
 
13847
13863
  worker.postMessage({type: 'machine-ready', lastBlock});
13848
- _worker.terminate();
13849
13864
 
13850
- worker.postMessage(blocks);
13865
+ // worker.postMessage({blocks});
13851
13866
  };
13852
13867
 
13853
13868
  const tasks = async (e) => {
@@ -13901,4 +13916,8 @@ const tasks = async (e) => {
13901
13916
 
13902
13917
  worker.onmessage(data => tasks(data));
13903
13918
 
13919
+
13920
+
13904
13921
  }();
13922
+ var __webpack_exports__unique = __webpack_exports__.T;
13923
+ export { __webpack_exports__unique as unique };
@@ -11723,6 +11723,11 @@ var __webpack_exports__ = {};
11723
11723
  // This entry need to be wrapped in an IIFE because it need to be isolated against other modules in the chunk.
11724
11724
  !function() {
11725
11725
 
11726
+ // EXPORTS
11727
+ __webpack_require__.d(__webpack_exports__, {
11728
+ "T": function() { return /* binding */ unique; }
11729
+ });
11730
+
11726
11731
  ;// CONCATENATED MODULE: ./node_modules/@vandeurenglenn/base-x/src/base-x.js
11727
11732
  // base-x encoding / decoding
11728
11733
  // Copyright (c) 2018 base-x contributors
@@ -13722,6 +13727,9 @@ globalThis.BigNumber = BigNumber;
13722
13727
  globalThis.peernet = globalThis.peernet || {};
13723
13728
  globalThis.contracts = {};
13724
13729
 
13730
+ const unique = arr => arr.filter((el, pos, arr) => {
13731
+ return arr.indexOf(el) == pos;
13732
+ });
13725
13733
 
13726
13734
  const get = (contract, method, params) => {
13727
13735
  let result;
@@ -13819,16 +13827,23 @@ const _init = async ({ contracts, blocks, peerid })=> {
13819
13827
 
13820
13828
  if (blocks?.length > 0) {
13821
13829
  const _worker = await new EasyWorker('./block-worker.js', {serialization: 'advanced', type: 'module' });
13822
- blocks = await _worker.once(blocks);
13830
+ blocks = await _worker.once([blocks[blocks.length - 1]]);
13823
13831
 
13824
- for (const block of blocks) {
13825
- await Promise.all(block.decoded.transactions.map(async message => {
13826
- const {from, to, method, params} = message;
13827
- globalThis.msg = createMessage(from);
13828
-
13829
- await execute(to, method, params);
13830
- }));
13831
- }
13832
+ // blocks = unique(globalThis.blocks ? globalThis : [], blocks)
13833
+ // for (let i = 0; i < blocks.length; i++) {
13834
+
13835
+ // }
13836
+ // for (const block of blocks) {
13837
+ // await Promise.all(block.decoded.transactions.map(async message => {
13838
+ // if (!block.loaded) {
13839
+ // const {from, to, method, params} = message;
13840
+ // globalThis.msg = createMessage(from);
13841
+
13842
+ // await execute(to, method, params);
13843
+ // block.loaded = true
13844
+ // }
13845
+ // }));
13846
+ // }
13832
13847
 
13833
13848
  if (blocks.length > 0) {
13834
13849
  lastBlock = blocks[blocks.length - 1].decoded;
@@ -13839,15 +13854,15 @@ const _init = async ({ contracts, blocks, peerid })=> {
13839
13854
  hash: await lastBlock.hash
13840
13855
  };
13841
13856
  }
13857
+ globalThis.blocks = blocks;
13842
13858
  }
13843
13859
 
13844
13860
 
13845
13861
 
13846
13862
 
13847
13863
  worker.postMessage({type: 'machine-ready', lastBlock});
13848
- _worker.terminate();
13849
13864
 
13850
- worker.postMessage(blocks);
13865
+ // worker.postMessage({blocks});
13851
13866
  };
13852
13867
 
13853
13868
  const tasks = async (e) => {
@@ -13901,4 +13916,8 @@ const tasks = async (e) => {
13901
13916
 
13902
13917
  worker.onmessage(data => tasks(data));
13903
13918
 
13919
+
13920
+
13904
13921
  }();
13922
+ var __webpack_exports__unique = __webpack_exports__.T;
13923
+ export { __webpack_exports__unique as unique };
@@ -58565,8 +58565,8 @@ class Machine {
58565
58565
  #nonces = {}
58566
58566
  lastBlock = {index: 0, hash: '0x0', previousHash: '0x0'}
58567
58567
 
58568
- constructor() {
58569
- return this.#init()
58568
+ constructor(blocks) {
58569
+ return this.#init(blocks)
58570
58570
  }
58571
58571
 
58572
58572
  #createMessage(sender = peernet.selectedAccount) {
@@ -58603,7 +58603,7 @@ class Machine {
58603
58603
 
58604
58604
  }
58605
58605
 
58606
- async #init() {
58606
+ async #init(blocks) {
58607
58607
  return new Promise(async (resolve) => {
58608
58608
  pubsub.subscribe('machine.ready', () => {
58609
58609
  resolve(this);
@@ -58612,7 +58612,7 @@ class Machine {
58612
58612
  this.worker = await new EasyWorker((0,path_browserify.join)(chain_dirname, './workers/machine-worker.js'), {serialization: 'advanced', type:'module'});
58613
58613
  this.worker.onmessage(this.#onmessage.bind(this));
58614
58614
 
58615
- const blocks = await blockStore.values();
58615
+ // const blocks = await blockStore.values()
58616
58616
  const contracts = await Promise.all([
58617
58617
  contractStore.get(contractFactory$1),
58618
58618
  contractStore.get(nativeToken$1),
@@ -59052,7 +59052,7 @@ class Chain {
59052
59052
  const initialized = await contractStore.has(addresses.contractFactory);
59053
59053
  if (!initialized) await this.#setup();
59054
59054
 
59055
- this.#machine = await new Machine();
59055
+
59056
59056
  this.utils = { BigNumber: BigNumber, formatUnits: formatUnits, parseUnits: parseUnits };
59057
59057
 
59058
59058
  try {
@@ -59096,6 +59096,11 @@ class Chain {
59096
59096
 
59097
59097
  // load local blocks
59098
59098
  await this.resolveBlocks();
59099
+ this.#machine = await new Machine(this.#blocks);
59100
+ // for (const block of this.#blocks) {
59101
+ // block.loaded = true
59102
+ // }
59103
+ await this.#loadBlocks(this.#blocks);
59099
59104
  return this
59100
59105
  }
59101
59106
 
@@ -59122,8 +59127,8 @@ class Chain {
59122
59127
  debug(`synced ${blocksSynced} ${blocksSynced > 1 ? 'blocks' : 'block'}`);
59123
59128
 
59124
59129
  this.#blocks.length;
59125
- (this.#blocks.length) - blocksSynced;
59126
- await this.#loadBlocks(this.#blocks);
59130
+ const start = (this.#blocks.length) - blocksSynced;
59131
+ await this.#loadBlocks(this.blocks.slice(start));
59127
59132
  this.#lastBlock = this.#blocks[this.#blocks.length - 1];
59128
59133
  const message = await new BlockMessage(this.lastBlock);
59129
59134
  await blockStore.put(await message.hash, message.encoded);
@@ -59155,9 +59160,9 @@ async resolveBlock(hash) {
59155
59160
  if (!await peernet.has(hash, 'block')) await peernet.put(hash, block.encoded, 'block');
59156
59161
  const size = block.encoded.length || block.encoded.byteLength;
59157
59162
  block = {...block.decoded, hash};
59158
- if (this.#blocks[block.index]) throw `invalid block ${hash} @${block.index}`
59163
+ if (this.#blocks[block.index] && this.#blocks[block.index].hash !== block.hash) throw `invalid block ${hash} @${block.index}`
59159
59164
  this.#blocks[block.index] = block;
59160
- console.log(`loaded block: ${hash} @${block.index} ${formatBytes(size)}`);
59165
+ console.log(`resolved block: ${hash} @${block.index} ${formatBytes(size)}`);
59161
59166
  if (block.previousHash !== '0x0') {
59162
59167
  return this.resolveBlock(block.previousHash)
59163
59168
  }
@@ -59171,7 +59176,7 @@ async resolveBlock(hash) {
59171
59176
  if (hash && hash !== '0x0')
59172
59177
  await this.resolveBlock(hash);
59173
59178
  this.#lastBlock = this.#blocks[this.#blocks.length - 1];
59174
- await this.#loadBlocks(this.#blocks);
59179
+
59175
59180
  } catch (e) {
59176
59181
  await chainStore.put('lastBlock', new TextEncoder().encode('0x0'));
59177
59182
  return this.resolveBlocks()
@@ -59190,7 +59195,8 @@ async resolveBlock(hash) {
59190
59195
  console.log(e);
59191
59196
  }
59192
59197
  }
59193
- block.loaded = true;
59198
+ this.#blocks[block.index].loaded = true;
59199
+ console.log(`loaded block: ${block.hash} @${block.index}`);
59194
59200
  // let message = await peernet.get(block.hash, 'block')
59195
59201
 
59196
59202
  // const compressed = pako.deflate(message);
@@ -59242,8 +59248,6 @@ async resolveBlock(hash) {
59242
59248
  // transaction = new TransactionMessage(transaction)
59243
59249
  // return transaction
59244
59250
  // }
59245
-
59246
- console.log(blockMessage);
59247
59251
  await Promise.all(blockMessage.decoded.transactions
59248
59252
  .map(async transaction => transactionPoolStore.delete(await transaction.hash)));
59249
59253
  const hash = await blockMessage.hash;
package/dist/chain.js CHANGED
@@ -64,8 +64,8 @@ class Machine {
64
64
  #nonces = {}
65
65
  lastBlock = {index: 0, hash: '0x0', previousHash: '0x0'}
66
66
 
67
- constructor() {
68
- return this.#init()
67
+ constructor(blocks) {
68
+ return this.#init(blocks)
69
69
  }
70
70
 
71
71
  #createMessage(sender = peernet.selectedAccount) {
@@ -102,7 +102,7 @@ class Machine {
102
102
 
103
103
  }
104
104
 
105
- async #init() {
105
+ async #init(blocks) {
106
106
  return new Promise(async (resolve) => {
107
107
  pubsub.subscribe('machine.ready', () => {
108
108
  resolve(this);
@@ -111,7 +111,7 @@ class Machine {
111
111
  this.worker = await new EasyWorker__default["default"](path.join(__dirname, './workers/machine-worker.js'), {serialization: 'advanced', type:'module'});
112
112
  this.worker.onmessage(this.#onmessage.bind(this));
113
113
 
114
- const blocks = await blockStore.values();
114
+ // const blocks = await blockStore.values()
115
115
  const contracts = await Promise.all([
116
116
  contractStore.get(contractFactory$1),
117
117
  contractStore.get(nativeToken$1),
@@ -551,7 +551,7 @@ class Chain {
551
551
  const initialized = await contractStore.has(addresses.contractFactory);
552
552
  if (!initialized) await this.#setup();
553
553
 
554
- this.#machine = await new Machine();
554
+
555
555
  this.utils = { BigNumber: utils.BigNumber, formatUnits: utils.formatUnits, parseUnits: utils.parseUnits };
556
556
 
557
557
  try {
@@ -595,6 +595,11 @@ class Chain {
595
595
 
596
596
  // load local blocks
597
597
  await this.resolveBlocks();
598
+ this.#machine = await new Machine(this.#blocks);
599
+ // for (const block of this.#blocks) {
600
+ // block.loaded = true
601
+ // }
602
+ await this.#loadBlocks(this.#blocks);
598
603
  return this
599
604
  }
600
605
 
@@ -621,8 +626,8 @@ class Chain {
621
626
  debug(`synced ${blocksSynced} ${blocksSynced > 1 ? 'blocks' : 'block'}`);
622
627
 
623
628
  this.#blocks.length;
624
- (this.#blocks.length) - blocksSynced;
625
- await this.#loadBlocks(this.#blocks);
629
+ const start = (this.#blocks.length) - blocksSynced;
630
+ await this.#loadBlocks(this.blocks.slice(start));
626
631
  this.#lastBlock = this.#blocks[this.#blocks.length - 1];
627
632
  const message = await new BlockMessage(this.lastBlock);
628
633
  await blockStore.put(await message.hash, message.encoded);
@@ -654,9 +659,9 @@ async resolveBlock(hash) {
654
659
  if (!await peernet.has(hash, 'block')) await peernet.put(hash, block.encoded, 'block');
655
660
  const size = block.encoded.length || block.encoded.byteLength;
656
661
  block = {...block.decoded, hash};
657
- if (this.#blocks[block.index]) throw `invalid block ${hash} @${block.index}`
662
+ if (this.#blocks[block.index] && this.#blocks[block.index].hash !== block.hash) throw `invalid block ${hash} @${block.index}`
658
663
  this.#blocks[block.index] = block;
659
- console.log(`loaded block: ${hash} @${block.index} ${formatBytes(size)}`);
664
+ console.log(`resolved block: ${hash} @${block.index} ${formatBytes(size)}`);
660
665
  if (block.previousHash !== '0x0') {
661
666
  return this.resolveBlock(block.previousHash)
662
667
  }
@@ -670,7 +675,7 @@ async resolveBlock(hash) {
670
675
  if (hash && hash !== '0x0')
671
676
  await this.resolveBlock(hash);
672
677
  this.#lastBlock = this.#blocks[this.#blocks.length - 1];
673
- await this.#loadBlocks(this.#blocks);
678
+
674
679
  } catch (e) {
675
680
  await chainStore.put('lastBlock', new TextEncoder().encode('0x0'));
676
681
  return this.resolveBlocks()
@@ -689,7 +694,8 @@ async resolveBlock(hash) {
689
694
  console.log(e);
690
695
  }
691
696
  }
692
- block.loaded = true;
697
+ this.#blocks[block.index].loaded = true;
698
+ console.log(`loaded block: ${block.hash} @${block.index}`);
693
699
  // let message = await peernet.get(block.hash, 'block')
694
700
 
695
701
  // const compressed = pako.deflate(message);
@@ -741,8 +747,6 @@ async resolveBlock(hash) {
741
747
  // transaction = new TransactionMessage(transaction)
742
748
  // return transaction
743
749
  // }
744
-
745
- console.log(blockMessage);
746
750
  await Promise.all(blockMessage.decoded.transactions
747
751
  .map(async transaction => transactionPoolStore.delete(await transaction.hash)));
748
752
  const hash = await blockMessage.hash;
@@ -55,8 +55,8 @@ class Machine {
55
55
  #nonces = {}
56
56
  lastBlock = {index: 0, hash: '0x0', previousHash: '0x0'}
57
57
 
58
- constructor() {
59
- return this.#init()
58
+ constructor(blocks) {
59
+ return this.#init(blocks)
60
60
  }
61
61
 
62
62
  #createMessage(sender = peernet.selectedAccount) {
@@ -93,7 +93,7 @@ class Machine {
93
93
 
94
94
  }
95
95
 
96
- async #init() {
96
+ async #init(blocks) {
97
97
  return new Promise(async (resolve) => {
98
98
  pubsub.subscribe('machine.ready', () => {
99
99
  resolve(this);
@@ -102,7 +102,7 @@ class Machine {
102
102
  this.worker = await new EasyWorker(join(__dirname, './workers/machine-worker.js'), {serialization: 'advanced', type:'module'});
103
103
  this.worker.onmessage(this.#onmessage.bind(this));
104
104
 
105
- const blocks = await blockStore.values();
105
+ // const blocks = await blockStore.values()
106
106
  const contracts = await Promise.all([
107
107
  contractStore.get(contractFactory$1),
108
108
  contractStore.get(nativeToken$1),
@@ -542,7 +542,7 @@ class Chain {
542
542
  const initialized = await contractStore.has(addresses.contractFactory);
543
543
  if (!initialized) await this.#setup();
544
544
 
545
- this.#machine = await new Machine();
545
+
546
546
  this.utils = { BigNumber, formatUnits, parseUnits };
547
547
 
548
548
  try {
@@ -586,6 +586,11 @@ class Chain {
586
586
 
587
587
  // load local blocks
588
588
  await this.resolveBlocks();
589
+ this.#machine = await new Machine(this.#blocks);
590
+ // for (const block of this.#blocks) {
591
+ // block.loaded = true
592
+ // }
593
+ await this.#loadBlocks(this.#blocks);
589
594
  return this
590
595
  }
591
596
 
@@ -612,8 +617,8 @@ class Chain {
612
617
  debug(`synced ${blocksSynced} ${blocksSynced > 1 ? 'blocks' : 'block'}`);
613
618
 
614
619
  this.#blocks.length;
615
- (this.#blocks.length) - blocksSynced;
616
- await this.#loadBlocks(this.#blocks);
620
+ const start = (this.#blocks.length) - blocksSynced;
621
+ await this.#loadBlocks(this.blocks.slice(start));
617
622
  this.#lastBlock = this.#blocks[this.#blocks.length - 1];
618
623
  const message = await new BlockMessage(this.lastBlock);
619
624
  await blockStore.put(await message.hash, message.encoded);
@@ -645,9 +650,9 @@ async resolveBlock(hash) {
645
650
  if (!await peernet.has(hash, 'block')) await peernet.put(hash, block.encoded, 'block');
646
651
  const size = block.encoded.length || block.encoded.byteLength;
647
652
  block = {...block.decoded, hash};
648
- if (this.#blocks[block.index]) throw `invalid block ${hash} @${block.index}`
653
+ if (this.#blocks[block.index] && this.#blocks[block.index].hash !== block.hash) throw `invalid block ${hash} @${block.index}`
649
654
  this.#blocks[block.index] = block;
650
- console.log(`loaded block: ${hash} @${block.index} ${formatBytes(size)}`);
655
+ console.log(`resolved block: ${hash} @${block.index} ${formatBytes(size)}`);
651
656
  if (block.previousHash !== '0x0') {
652
657
  return this.resolveBlock(block.previousHash)
653
658
  }
@@ -661,7 +666,7 @@ async resolveBlock(hash) {
661
666
  if (hash && hash !== '0x0')
662
667
  await this.resolveBlock(hash);
663
668
  this.#lastBlock = this.#blocks[this.#blocks.length - 1];
664
- await this.#loadBlocks(this.#blocks);
669
+
665
670
  } catch (e) {
666
671
  await chainStore.put('lastBlock', new TextEncoder().encode('0x0'));
667
672
  return this.resolveBlocks()
@@ -680,7 +685,8 @@ async resolveBlock(hash) {
680
685
  console.log(e);
681
686
  }
682
687
  }
683
- block.loaded = true;
688
+ this.#blocks[block.index].loaded = true;
689
+ console.log(`loaded block: ${block.hash} @${block.index}`);
684
690
  // let message = await peernet.get(block.hash, 'block')
685
691
 
686
692
  // const compressed = pako.deflate(message);
@@ -732,8 +738,6 @@ async resolveBlock(hash) {
732
738
  // transaction = new TransactionMessage(transaction)
733
739
  // return transaction
734
740
  // }
735
-
736
- console.log(blockMessage);
737
741
  await Promise.all(blockMessage.decoded.transactions
738
742
  .map(async transaction => transactionPoolStore.delete(await transaction.hash)));
739
743
  const hash = await blockMessage.hash;
@@ -388,6 +388,9 @@ globalThis.BigNumber = BigNumber;
388
388
  globalThis.peernet = globalThis.peernet || {};
389
389
  globalThis.contracts = {};
390
390
 
391
+ const unique = arr => arr.filter((el, pos, arr) => {
392
+ return arr.indexOf(el) == pos;
393
+ });
391
394
 
392
395
  const get = (contract, method, params) => {
393
396
  let result;
@@ -485,16 +488,23 @@ const _init = async ({ contracts, blocks, peerid })=> {
485
488
 
486
489
  if (blocks?.length > 0) {
487
490
  const _worker = await new EasyWorker('./block-worker.js', {serialization: 'advanced', type: 'module' });
488
- blocks = await _worker.once(blocks);
491
+ blocks = await _worker.once([blocks[blocks.length - 1]]);
489
492
 
490
- for (const block of blocks) {
491
- await Promise.all(block.decoded.transactions.map(async message => {
492
- const {from, to, method, params} = message;
493
- globalThis.msg = createMessage(from);
494
-
495
- await execute(to, method, params);
496
- }));
497
- }
493
+ // blocks = unique(globalThis.blocks ? globalThis : [], blocks)
494
+ // for (let i = 0; i < blocks.length; i++) {
495
+
496
+ // }
497
+ // for (const block of blocks) {
498
+ // await Promise.all(block.decoded.transactions.map(async message => {
499
+ // if (!block.loaded) {
500
+ // const {from, to, method, params} = message;
501
+ // globalThis.msg = createMessage(from);
502
+
503
+ // await execute(to, method, params);
504
+ // block.loaded = true
505
+ // }
506
+ // }));
507
+ // }
498
508
 
499
509
  if (blocks.length > 0) {
500
510
  lastBlock = blocks[blocks.length - 1].decoded;
@@ -505,15 +515,15 @@ const _init = async ({ contracts, blocks, peerid })=> {
505
515
  hash: await lastBlock.hash
506
516
  };
507
517
  }
518
+ globalThis.blocks = blocks;
508
519
  }
509
520
 
510
521
 
511
522
 
512
523
 
513
524
  worker.postMessage({type: 'machine-ready', lastBlock});
514
- _worker.terminate();
515
525
 
516
- worker.postMessage(blocks);
526
+ // worker.postMessage({blocks});
517
527
  };
518
528
 
519
529
  const tasks = async (e) => {
@@ -566,3 +576,5 @@ const tasks = async (e) => {
566
576
  };
567
577
 
568
578
  worker.onmessage(data => tasks(data));
579
+
580
+ export { unique };
@@ -436,7 +436,7 @@ class Peer {
436
436
  this.#connection.ondatachannel = (message) => {
437
437
  message.channel.onopen = () => {
438
438
  this.#connected = true
439
- debug(`peer:connected ${this}`)
439
+ // debug(`peer:connected ${this}`)
440
440
  pubsub.publish('peer:connected', this)
441
441
  }
442
442
  message.channel.onclose = () => this.close.bind(this)
@@ -473,7 +473,7 @@ class Peer {
473
473
  }
474
474
 
475
475
  _handleMessage(peerId, message) {
476
- debug(`incoming message from ${peerId}`)
476
+ // debug(`incoming message from ${peerId}`)
477
477
 
478
478
  message = JSON.parse(new TextDecoder().decode(message.data))
479
479
  // allow sharding (multiple peers share data)
@@ -515,7 +515,7 @@ class Peer {
515
515
 
516
516
 
517
517
  if (message.candidate) {
518
- debug(`incoming candidate ${this.#channelName}`)
518
+ // debug(`incoming candidate ${this.#channelName}`)
519
519
  // debug(message.candidate.candidate)
520
520
  this.remoteAddress = message.candidate.address
521
521
  this.remotePort = message.candidate.port
@@ -526,14 +526,14 @@ class Peer {
526
526
  try {
527
527
  if (message.sdp) {
528
528
  if (message.sdp.type === 'offer') {
529
- debug(`incoming offer ${this.#channelName}`)
529
+ // debug(`incoming offer ${this.#channelName}`)
530
530
  await this.#connection.setRemoteDescription(new wrtc.RTCSessionDescription(message.sdp))
531
531
  const answer = await this.#connection.createAnswer();
532
532
  await this.#connection.setLocalDescription(answer)
533
533
  this._sendMessage({'sdp': this.#connection.localDescription})
534
534
  }
535
535
  if (message.sdp.type === 'answer') {
536
- debug(`incoming answer ${this.#channelName}`)
536
+ // debug(`incoming answer ${this.#channelName}`)
537
537
  await this.#connection.setRemoteDescription(new wrtc.RTCSessionDescription(message.sdp))
538
538
  }
539
539
  }
@@ -543,7 +543,7 @@ class Peer {
543
543
  }
544
544
 
545
545
  close() {
546
- debug(`closing ${this.peerId}`)
546
+ // debug(`closing ${this.peerId}`)
547
547
  this.#connected = false
548
548
  this.#channel?.close()
549
549
  this.#connection?.close()
@@ -578,11 +578,10 @@ class Client {
578
578
  this.starJoined = this.starJoined.bind(this)
579
579
  this.networkVersion = networkVersion
580
580
 
581
- this._init(network, stars)
581
+ this._init(stars)
582
582
  }
583
583
 
584
- async _init(network, stars = [], networkVersion) {
585
- this.network = network
584
+ async _init(stars = []) {
586
585
  this.starsConfig = stars
587
586
  // reconnectJob()
588
587
 
@@ -1 +1 @@
1
- "use strict";var e=require("@leofcoin/codec-format-interface"),t=require("bn.js"),r=require("@ethersproject/bytes"),s=require("@ethersproject/logger");require("@ethersproject/bignumber"),require("path");var n=require("@vandeurenglenn/easy-worker");function i(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var a=i(t),o=i(n);class ContractMessage extends e.FormatInterface{get keys(){return["creator","contract","constructorParameters"]}get messageName(){return"ContractMessage"}constructor(e){super(e,"\nmessage ContractMessage {\n required string creator = 1;\n required bytes contract = 2;\n repeated string constructorParameters = 3;\n}\n",{name:"contract-message"})}}class BlockMessage extends e.FormatInterface{get keys(){return["index","previousHash","timestamp","reward","fees","transactions","validators"]}get messageName(){return"BlockMessage"}constructor(e){super(e,"\nmessage ValidatorMessage {\n required string address = 1;\n required string reward = 2;\n}\n\nmessage Transaction {\n required string hash = 1;\n required uint64 timestamp = 2;\n required string from = 3;\n required string to = 4;\n required uint64 nonce = 5;\n required string method = 6;\n repeated string params = 7;\n}\n\nmessage BlockMessage {\n required uint64 index = 1;\n required string previousHash = 3;\n required uint64 timestamp = 4;\n required uint64 reward = 5;\n required string fees = 6;\n repeated Transaction transactions = 7;\n repeated ValidatorMessage validators = 8;\n}\n",{name:"block-message"})}}var u=a.default.BN;const g=new s.Logger("bignumber/5.6.2"),c={};let h=!1;class BigNumber{constructor(e,t){e!==c&&g.throwError("cannot call constructor directly; use BigNumber.from",s.Logger.errors.UNSUPPORTED_OPERATION,{operation:"new (BigNumber)"}),this._hex=t,this._isBigNumber=!0,Object.freeze(this)}fromTwos(e){return l(d(this).fromTwos(e))}toTwos(e){return l(d(this).toTwos(e))}abs(){return"-"===this._hex[0]?BigNumber.from(this._hex.substring(1)):this}add(e){return l(d(this).add(d(e)))}sub(e){return l(d(this).sub(d(e)))}div(e){return BigNumber.from(e).isZero()&&p("division-by-zero","div"),l(d(this).div(d(e)))}mul(e){return l(d(this).mul(d(e)))}mod(e){const t=d(e);return t.isNeg()&&p("division-by-zero","mod"),l(d(this).umod(t))}pow(e){const t=d(e);return t.isNeg()&&p("negative-power","pow"),l(d(this).pow(t))}and(e){const t=d(e);return(this.isNegative()||t.isNeg())&&p("unbound-bitwise-result","and"),l(d(this).and(t))}or(e){const t=d(e);return(this.isNegative()||t.isNeg())&&p("unbound-bitwise-result","or"),l(d(this).or(t))}xor(e){const t=d(e);return(this.isNegative()||t.isNeg())&&p("unbound-bitwise-result","xor"),l(d(this).xor(t))}mask(e){return(this.isNegative()||e<0)&&p("negative-width","mask"),l(d(this).maskn(e))}shl(e){return(this.isNegative()||e<0)&&p("negative-width","shl"),l(d(this).shln(e))}shr(e){return(this.isNegative()||e<0)&&p("negative-width","shr"),l(d(this).shrn(e))}eq(e){return d(this).eq(d(e))}lt(e){return d(this).lt(d(e))}lte(e){return d(this).lte(d(e))}gt(e){return d(this).gt(d(e))}gte(e){return d(this).gte(d(e))}isNegative(){return"-"===this._hex[0]}isZero(){return d(this).isZero()}toNumber(){try{return d(this).toNumber()}catch(e){p("overflow","toNumber",this.toString())}return null}toBigInt(){try{return BigInt(this.toString())}catch(e){}return g.throwError("this platform does not support BigInt",s.Logger.errors.UNSUPPORTED_OPERATION,{value:this.toString()})}toString(){return arguments.length>0&&(10===arguments[0]?h||(h=!0,g.warn("BigNumber.toString does not accept any parameters; base-10 is assumed")):16===arguments[0]?g.throwError("BigNumber.toString does not accept any parameters; use bigNumber.toHexString()",s.Logger.errors.UNEXPECTED_ARGUMENT,{}):g.throwError("BigNumber.toString does not accept parameters",s.Logger.errors.UNEXPECTED_ARGUMENT,{})),d(this).toString(10)}toHexString(){return this._hex}toJSON(e){return{type:"BigNumber",hex:this.toHexString()}}static from(e){if(e instanceof BigNumber)return e;if("string"==typeof e)return e.match(/^-?0x[0-9a-f]+$/i)?new BigNumber(c,m(e)):e.match(/^-?[0-9]+$/)?new BigNumber(c,m(new u(e))):g.throwArgumentError("invalid BigNumber string","value",e);if("number"==typeof e)return e%1&&p("underflow","BigNumber.from",e),(e>=9007199254740991||e<=-9007199254740991)&&p("overflow","BigNumber.from",e),BigNumber.from(String(e));const t=e;if("bigint"==typeof t)return BigNumber.from(t.toString());if(r.isBytes(t))return BigNumber.from(r.hexlify(t));if(t)if(t.toHexString){const e=t.toHexString();if("string"==typeof e)return BigNumber.from(e)}else{let e=t._hex;if(null==e&&"BigNumber"===t.type&&(e=t.hex),"string"==typeof e&&(r.isHexString(e)||"-"===e[0]&&r.isHexString(e.substring(1))))return BigNumber.from(e)}return g.throwArgumentError("invalid BigNumber value","value",e)}static isBigNumber(e){return!(!e||!e._isBigNumber)}}function m(e){if("string"!=typeof e)return m(e.toString(16));if("-"===e[0])return"-"===(e=e.substring(1))[0]&&g.throwArgumentError("invalid hex","value",e),"0x00"===(e=m(e))?e:"-"+e;if("0x"!==e.substring(0,2)&&(e="0x"+e),"0x"===e)return"0x00";for(e.length%2&&(e="0x0"+e.substring(2));e.length>4&&"0x00"===e.substring(0,4);)e="0x"+e.substring(4);return e}function l(e){return BigNumber.from(m(e))}function d(e){const t=BigNumber.from(e).toHexString();return"-"===t[0]?new u("-"+t.substring(3),16):new u(t.substring(2),16)}function p(e,t,r){const n={fault:e,operation:t};return null!=r&&(n.value=r),g.throwError(e,s.Logger.errors.NUMERIC_FAULT,n)}new s.Logger("units/5.6.1");const b=["Bytes","KB","MB","GB","TB","PB","EB","ZB","YB"],f=(e,t=2)=>{if(0===e)return"0 Bytes";t<0&&(t=0);const r=Math.floor(Math.log(e)/Math.log(1024));return`${parseFloat((e/Math.pow(1024,r)).toFixed(t))} ${b[r]}`};var w="237,198,141,3,123,34,99,114,101,97,116,111,114,34,58,34,56,71,85,107,103,52,120,87,113,109,110,83,56,75,101,122,56,107,54,68,115,82,120,90,66,68,97,54,114,71,74,109,104,107,122,67,75,113,78,75,102,85,110,103,90,122,109,54,97,81,34,44,34,99,111,110,116,114,97,99,116,34,58,34,114,101,116,117,114,110,32,99,108,97,115,115,32,70,97,99,116,111,114,121,123,35,110,97,109,101,61,92,34,65,114,116,79,110,108,105,110,101,67,111,110,116,114,97,99,116,70,97,99,116,111,114,121,92,34,59,35,116,111,116,97,108,67,111,110,116,114,97,99,116,115,61,48,59,35,99,111,110,116,114,97,99,116,115,61,91,93,59,99,111,110,115,116,114,117,99,116,111,114,40,115,116,97,116,101,41,123,115,116,97,116,101,38,38,40,116,104,105,115,46,35,99,111,110,116,114,97,99,116,115,61,115,116,97,116,101,46,99,111,110,116,114,97,99,116,115,44,116,104,105,115,46,35,116,111,116,97,108,67,111,110,116,114,97,99,116,115,61,115,116,97,116,101,46,116,111,116,97,108,67,111,110,116,114,97,99,116,115,41,125,103,101,116,32,115,116,97,116,101,40,41,123,114,101,116,117,114,110,123,116,111,116,97,108,67,111,110,116,114,97,99,116,115,58,116,104,105,115,46,35,116,111,116,97,108,67,111,110,116,114,97,99,116,115,44,99,111,110,116,114,97,99,116,115,58,116,104,105,115,46,35,99,111,110,116,114,97,99,116,115,125,125,103,101,116,32,110,97,109,101,40,41,123,114,101,116,117,114,110,32,116,104,105,115,46,35,110,97,109,101,125,103,101,116,32,99,111,110,116,114,97,99,116,115,40,41,123,114,101,116,117,114,110,91,46,46,46,116,104,105,115,46,35,99,111,110,116,114,97,99,116,115,93,125,103,101,116,32,116,111,116,97,108,67,111,110,116,114,97,99,116,115,40,41,123,114,101,116,117,114,110,32,116,104,105,115,46,35,116,111,116,97,108,67,111,110,116,114,97,99,116,115,125,105,115,118,97,108,105,100,40,104,97,115,104,44,99,114,101,97,116,111,114,44,99,111,110,116,114,97,99,116,44,99,111,110,115,116,114,117,99,116,111,114,80,97,114,97,109,101,116,101,114,115,61,91,93,41,123,99,111,110,115,116,32,109,101,115,115,97,103,101,61,110,101,119,32,67,111,110,116,114,97,99,116,77,101,115,115,97,103,101,40,123,99,114,101,97,116,111,114,44,99,111,110,116,114,97,99,116,44,99,111,110,115,116,114,117,99,116,111,114,80,97,114,97,109,101,116,101,114,115,125,41,59,114,101,116,117,114,110,32,66,111,111,108,101,97,110,40,109,101,115,115,97,103,101,46,104,97,115,104,61,61,61,104,97,115,104,41,125,97,115,121,110,99,32,100,101,112,108,111,121,67,111,110,116,114,97,99,116,40,99,111,110,116,114,97,99,116,72,97,115,104,44,99,114,101,97,116,111,114,44,99,111,110,116,114,97,99,116,44,99,111,110,115,116,114,117,99,116,111,114,80,97,114,97,109,101,116,101,114,115,61,91,93,41,123,105,102,40,99,111,110,116,114,97,99,116,46,99,114,101,97,116,111,114,33,61,61,109,115,103,46,115,101,110,100,101,114,41,116,104,114,111,119,32,110,101,119,32,69,114,114,111,114,40,92,34,111,110,108,121,32,97,32,99,111,110,116,114,97,99,116,32,99,114,101,97,116,111,114,32,99,97,110,32,100,101,112,108,111,121,32,97,32,99,111,110,116,114,97,99,116,92,34,41,59,105,102,40,97,119,97,105,116,32,99,111,110,116,114,97,99,116,83,116,111,114,101,46,104,97,115,40,104,97,115,104,41,41,116,104,114,111,119,32,110,101,119,32,69,114,114,111,114,40,92,34,100,117,112,108,105,99,97,116,101,32,99,111,110,116,114,97,99,116,92,34,41,59,105,102,40,33,116,104,105,115,46,105,115,86,97,108,105,100,40,99,111,110,116,114,97,99,116,72,97,115,104,44,99,114,101,97,116,111,114,44,99,111,110,116,114,97,99,116,44,99,111,110,115,116,114,117,99,116,111,114,80,97,114,97,109,101,116,101,114,115,41,41,116,104,114,111,119,32,110,101,119,32,69,114,114,111,114,40,92,34,105,110,118,97,108,105,100,32,99,111,110,116,114,97,99,116,92,34,41,59,97,119,97,105,116,32,99,111,110,116,114,97,99,116,83,116,111,114,101,46,112,117,116,40,104,97,115,104,44,101,110,99,111,100,101,100,41,44,116,104,105,115,46,35,116,111,116,97,108,67,111,110,116,114,97,99,116,115,43,61,49,44,116,104,105,115,46,35,99,111,110,116,114,97,99,116,115,46,112,117,115,104,40,104,97,115,104,41,125,125,59,34,44,34,99,111,110,115,116,114,117,99,116,111,114,80,97,114,97,109,101,116,101,114,115,34,58,91,93,125",N="237,198,141,3,123,34,99,114,101,97,116,111,114,34,58,34,56,71,85,107,103,52,120,87,113,109,110,83,56,75,101,122,56,107,54,68,115,82,120,90,66,68,97,54,114,71,74,109,104,107,122,67,75,113,78,75,102,85,110,103,90,122,109,54,97,81,34,44,34,99,111,110,116,114,97,99,116,34,58,34,114,101,116,117,114,110,32,99,108,97,115,115,32,65,114,116,79,110,108,105,110,101,32,101,120,116,101,110,100,115,32,99,108,97,115,115,32,84,111,107,101,110,32,101,120,116,101,110,100,115,32,99,108,97,115,115,32,82,111,108,101,115,123,35,114,111,108,101,115,61,123,79,87,78,69,82,58,91,93,44,77,73,78,84,58,91,93,44,66,85,82,78,58,91,93,125,59,99,111,110,115,116,114,117,99,116,111,114,40,114,111,108,101,115,41,123,105,102,40,114,111,108,101,115,41,123,105,102,40,33,40,114,111,108,101,115,32,105,110,115,116,97,110,99,101,111,102,32,79,98,106,101,99,116,41,41,116,104,114,111,119,32,110,101,119,32,69,114,114,111,114,40,92,34,101,120,112,101,99,116,101,100,32,114,111,108,101,115,32,116,111,32,98,101,32,97,110,32,111,98,106,101,99,116,92,34,41,59,116,104,105,115,46,35,114,111,108,101,115,61,123,46,46,46,114,111,108,101,115,44,46,46,46,116,104,105,115,46,35,114,111,108,101,115,125,125,101,108,115,101,32,116,104,105,115,46,35,103,114,97,110,116,82,111,108,101,40,109,115,103,46,115,101,110,100,101,114,44,92,34,79,87,78,69,82,92,34,41,125,103,101,116,32,115,116,97,116,101,40,41,123,114,101,116,117,114,110,123,114,111,108,101,115,58,116,104,105,115,46,114,111,108,101,115,125,125,103,101,116,32,114,111,108,101,115,40,41,123,114,101,116,117,114,110,123,46,46,46,116,104,105,115,46,35,114,111,108,101,115,125,125,104,97,115,82,111,108,101,40,97,100,100,114,101,115,115,44,114,111,108,101,41,123,114,101,116,117,114,110,33,33,116,104,105,115,46,35,114,111,108,101,115,91,114,111,108,101,93,38,38,45,49,33,61,61,116,104,105,115,46,35,114,111,108,101,115,91,114,111,108,101,93,46,105,110,100,101,120,79,102,40,97,100,100,114,101,115,115,41,125,35,103,114,97,110,116,82,111,108,101,40,97,100,100,114,101,115,115,44,114,111,108,101,41,123,105,102,40,116,104,105,115,46,104,97,115,82,111,108,101,40,97,100,100,114,101,115,115,44,114,111,108,101,41,41,116,104,114,111,119,32,110,101,119,32,69,114,114,111,114,40,96,36,123,114,111,108,101,125,32,114,111,108,101,32,97,108,114,101,97,100,121,32,103,114,97,110,116,101,100,32,102,111,114,32,36,123,97,100,100,114,101,115,115,125,96,41,59,116,104,105,115,46,35,114,111,108,101,115,91,114,111,108,101,93,46,112,117,115,104,40,97,100,100,114,101,115,115,41,125,35,114,101,118,111,107,101,82,111,108,101,40,97,100,100,114,101,115,115,44,114,111,108,101,41,123,105,102,40,33,116,104,105,115,46,104,97,115,82,111,108,101,40,97,100,100,114,101,115,115,44,114,111,108,101,41,41,116,104,114,111,119,32,110,101,119,32,69,114,114,111,114,40,96,36,123,114,111,108,101,125,32,114,111,108,101,32,97,108,114,101,97,100,121,32,114,101,118,111,107,101,100,32,102,111,114,32,36,123,97,100,100,114,101,115,115,125,96,41,59,105,102,40,92,34,79,87,78,69,82,92,34,61,61,61,114,111,108,101,38,38,49,61,61,61,116,104,105,115,46,35,114,111,108,101,115,91,114,111,108,101,93,46,108,101,110,103,116,104,41,116,104,114,111,119,32,110,101,119,32,69,114,114,111,114,40,92,34,97,116,108,101,97,115,116,32,111,110,101,32,111,119,110,101,114,32,105,115,32,110,101,101,100,101,100,33,92,34,41,59,116,104,105,115,46,35,114,111,108,101,115,91,114,111,108,101,93,46,115,112,108,105,99,101,40,116,104,105,115,46,35,114,111,108,101,115,91,114,111,108,101,93,46,105,110,100,101,120,79,102,40,97,100,100,114,101,115,115,41,41,125,103,114,97,110,116,82,111,108,101,40,97,100,100,114,101,115,115,44,114,111,108,101,41,123,105,102,40,33,116,104,105,115,46,104,97,115,82,111,108,101,40,97,100,100,114,101,115,115,44,92,34,79,87,78,69,82,92,34,41,41,116,104,114,111,119,32,110,101,119,32,69,114,114,111,114,40,92,34,78,111,116,32,97,108,108,111,119,101,100,92,34,41,59,116,104,105,115,46,35,103,114,97,110,116,82,111,108,101,40,97,100,100,114,101,115,115,44,114,111,108,101,41,125,114,101,118,111,107,101,82,111,108,101,40,97,100,100,114,101,115,115,44,114,111,108,101,41,123,105,102,40,33,116,104,105,115,46,104,97,115,82,111,108,101,40,97,100,100,114,101,115,115,44,92,34,79,87,78,69,82,92,34,41,41,116,104,114,111,119,32,110,101,119,32,69,114,114,111,114,40,92,34,78,111,116,32,97,108,108,111,119,101,100,92,34,41,59,116,104,105,115,46,35,114,101,118,111,107,101,82,111,108,101,40,97,100,100,114,101,115,115,44,114,111,108,101,41,125,125,123,35,110,97,109,101,59,35,115,121,109,98,111,108,59,35,104,111,108,100,101,114,115,61,48,59,35,98,97,108,97,110,99,101,115,61,123,125,59,35,97,112,112,114,111,118,97,108,115,61,123,125,59,35,100,101,99,105,109,97,108,115,61,49,56,59,35,116,111,116,97,108,83,117,112,112,108,121,61,66,105,103,78,117,109,98,101,114,46,102,114,111,109,40,48,41,59,99,111,110,115,116,114,117,99,116,111,114,40,110,97,109,101,44,115,121,109,98,111,108,44,100,101,99,105,109,97,108,115,61,49,56,44,115,116,97,116,101,41,123,105,102,40,33,110,97,109,101,41,116,104,114,111,119,32,110,101,119,32,69,114,114,111,114,40,92,34,110,97,109,101,32,117,110,100,101,102,105,110,101,100,92,34,41,59,105,102,40,33,115,121,109,98,111,108,41,116,104,114,111,119,32,110,101,119,32,69,114,114,111,114,40,92,34,115,121,109,98,111,108,32,117,110,100,101,102,105,110,101,100,92,34,41,59,115,117,112,101,114,40,115,116,97,116,101,63,46,114,111,108,101,115,41,44,116,104,105,115,46,35,110,97,109,101,61,110,97,109,101,44,116,104,105,115,46,35,115,121,109,98,111,108,61,115,121,109,98,111,108,44,116,104,105,115,46,35,100,101,99,105,109,97,108,115,61,100,101,99,105,109,97,108,115,125,103,101,116,32,115,116,97,116,101,40,41,123,114,101,116,117,114,110,123,46,46,46,115,117,112,101,114,46,115,116,97,116,101,44,104,111,108,100,101,114,115,58,116,104,105,115,46,104,111,108,100,101,114,115,44,98,97,108,97,110,99,101,115,58,116,104,105,115,46,98,97,108,97,110,99,101,115,44,97,112,112,114,111,118,97,108,115,58,123,46,46,46,116,104,105,115,46,35,97,112,112,114,111,118,97,108,115,125,44,116,111,116,97,108,83,117,112,112,108,121,58,116,104,105,115,46,116,111,116,97,108,83,117,112,112,108,121,125,125,103,101,116,32,116,111,116,97,108,83,117,112,112,108,121,40,41,123,114,101,116,117,114,110,32,116,104,105,115,46,35,116,111,116,97,108,83,117,112,112,108,121,125,103,101,116,32,110,97,109,101,40,41,123,114,101,116,117,114,110,32,116,104,105,115,46,35,110,97,109,101,125,103,101,116,32,115,121,109,98,111,108,40,41,123,114,101,116,117,114,110,32,116,104,105,115,46,35,115,121,109,98,111,108,125,103,101,116,32,104,111,108,100,101,114,115,40,41,123,114,101,116,117,114,110,32,116,104,105,115,46,35,104,111,108,100,101,114,115,125,103,101,116,32,98,97,108,97,110,99,101,115,40,41,123,114,101,116,117,114,110,123,46,46,46,116,104,105,115,46,35,98,97,108,97,110,99,101,115,125,125,109,105,110,116,40,116,111,44,97,109,111,117,110,116,41,123,105,102,40,33,116,104,105,115,46,104,97,115,82,111,108,101,40,109,115,103,46,115,101,110,100,101,114,44,92,34,77,73,78,84,92,34,41,41,116,104,114,111,119,32,110,101,119,32,69,114,114,111,114,40,92,34,110,111,116,32,97,108,108,111,119,101,100,92,34,41,59,116,104,105,115,46,35,116,111,116,97,108,83,117,112,112,108,121,61,116,104,105,115,46,35,116,111,116,97,108,83,117,112,112,108,121,46,97,100,100,40,97,109,111,117,110,116,41,44,116,104,105,115,46,35,105,110,99,114,101,97,115,101,66,97,108,97,110,99,101,40,116,111,44,97,109,111,117,110,116,41,125,98,117,114,110,40,116,111,44,97,109,111,117,110,116,41,123,105,102,40,33,116,104,105,115,46,104,97,115,82,111,108,101,40,109,115,103,46,115,101,110,100,101,114,44,92,34,66,85,82,78,92,34,41,41,116,104,114,111,119,32,110,101,119,32,69,114,114,111,114,40,92,34,110,111,116,32,97,108,108,111,119,101,100,92,34,41,59,116,104,105,115,46,35,116,111,116,97,108,83,117,112,112,108,121,61,116,104,105,115,46,35,116,111,116,97,108,83,117,112,112,108,121,46,115,117,98,40,97,109,111,117,110,116,41,44,116,104,105,115,46,35,100,101,99,114,101,97,115,101,66,97,108,97,110,99,101,40,116,111,44,97,109,111,117,110,116,41,125,35,98,101,102,111,114,101,84,114,97,110,115,102,101,114,40,102,114,111,109,44,116,111,44,97,109,111,117,110,116,41,123,105,102,40,33,116,104,105,115,46,35,98,97,108,97,110,99,101,115,91,102,114,111,109,93,124,124,116,104,105,115,46,35,98,97,108,97,110,99,101,115,91,102,114,111,109,93,60,97,109,111,117,110,116,41,116,104,114,111,119,32,110,101,119,32,69,114,114,111,114,40,92,34,97,109,111,117,110,116,32,101,120,99,101,101,100,115,32,98,97,108,97,110,99,101,92,34,41,125,35,117,112,100,97,116,101,72,111,108,100,101,114,115,40,97,100,100,114,101,115,115,44,112,114,101,118,105,111,117,115,66,97,108,97,110,99,101,41,123,92,34,48,120,48,48,92,34,61,61,61,116,104,105,115,46,35,98,97,108,97,110,99,101,115,91,97,100,100,114,101,115,115,93,46,116,111,72,101,120,83,116,114,105,110,103,40,41,63,116,104,105,115,46,35,104,111,108,100,101,114,115,45,61,49,58,92,34,48,120,48,48,92,34,33,61,61,116,104,105,115,46,35,98,97,108,97,110,99,101,115,91,97,100,100,114,101,115,115,93,46,116,111,72,101,120,83,116,114,105,110,103,40,41,38,38,92,34,48,120,48,48,92,34,61,61,61,112,114,101,118,105,111,117,115,66,97,108,97,110,99,101,46,116,111,72,101,120,83,116,114,105,110,103,40,41,38,38,40,116,104,105,115,46,35,104,111,108,100,101,114,115,43,61,49,41,125,35,105,110,99,114,101,97,115,101,66,97,108,97,110,99,101,40,97,100,100,114,101,115,115,44,97,109,111,117,110,116,41,123,116,104,105,115,46,35,98,97,108,97,110,99,101,115,91,97,100,100,114,101,115,115,93,124,124,40,116,104,105,115,46,35,98,97,108,97,110,99,101,115,91,97,100,100,114,101,115,115,93,61,66,105,103,78,117,109,98,101,114,46,102,114,111,109,40,48,41,41,59,99,111,110,115,116,32,112,114,101,118,105,111,117,115,66,97,108,97,110,99,101,61,116,104,105,115,46,35,98,97,108,97,110,99,101,115,91,97,100,100,114,101,115,115,93,59,116,104,105,115,46,35,98,97,108,97,110,99,101,115,91,97,100,100,114,101,115,115,93,61,116,104,105,115,46,35,98,97,108,97,110,99,101,115,91,97,100,100,114,101,115,115,93,46,97,100,100,40,97,109,111,117,110,116,41,44,116,104,105,115,46,35,117,112,100,97,116,101,72,111,108,100,101,114,115,40,97,100,100,114,101,115,115,44,112,114,101,118,105,111,117,115,66,97,108,97,110,99,101,41,125,35,100,101,99,114,101,97,115,101,66,97,108,97,110,99,101,40,97,100,100,114,101,115,115,44,97,109,111,117,110,116,41,123,99,111,110,115,116,32,112,114,101,118,105,111,117,115,66,97,108,97,110,99,101,61,116,104,105,115,46,35,98,97,108,97,110,99,101,115,91,97,100,100,114,101,115,115,93,59,116,104,105,115,46,35,98,97,108,97,110,99,101,115,91,97,100,100,114,101,115,115,93,61,116,104,105,115,46,35,98,97,108,97,110,99,101,115,91,97,100,100,114,101,115,115,93,46,115,117,98,40,97,109,111,117,110,116,41,44,116,104,105,115,46,35,117,112,100,97,116,101,72,111,108,100,101,114,115,40,97,100,100,114,101,115,115,44,112,114,101,118,105,111,117,115,66,97,108,97,110,99,101,41,125,98,97,108,97,110,99,101,79,102,40,97,100,100,114,101,115,115,41,123,114,101,116,117,114,110,32,116,104,105,115,46,35,98,97,108,97,110,99,101,115,91,97,100,100,114,101,115,115,93,125,115,101,116,65,112,112,114,111,118,97,108,40,111,112,101,114,97,116,111,114,44,97,109,111,117,110,116,41,123,99,111,110,115,116,32,111,119,110,101,114,61,103,108,111,98,97,108,84,104,105,115,46,109,115,103,46,115,101,110,100,101,114,59,116,104,105,115,46,35,97,112,112,114,111,118,97,108,115,91,111,119,110,101,114,93,124,124,40,116,104,105,115,46,35,97,112,112,114,111,118,97,108,115,91,111,119,110,101,114,93,61,123,125,41,44,116,104,105,115,46,35,97,112,112,114,111,118,97,108,115,91,111,119,110,101,114,93,91,111,112,101,114,97,116,111,114,93,61,97,109,111,117,110,116,125,97,112,112,114,111,118,101,100,40,111,119,110,101,114,44,111,112,101,114,97,116,111,114,44,97,109,111,117,110,116,41,123,114,101,116,117,114,110,32,116,104,105,115,46,35,97,112,112,114,111,118,97,108,115,91,111,119,110,101,114,93,91,111,112,101,114,97,116,111,114,93,61,61,61,97,109,111,117,110,116,125,116,114,97,110,115,102,101,114,40,102,114,111,109,44,116,111,44,97,109,111,117,110,116,41,123,97,109,111,117,110,116,61,66,105,103,78,117,109,98,101,114,46,102,114,111,109,40,97,109,111,117,110,116,41,44,116,104,105,115,46,35,98,101,102,111,114,101,84,114,97,110,115,102,101,114,40,102,114,111,109,44,116,111,44,97,109,111,117,110,116,41,44,116,104,105,115,46,35,100,101,99,114,101,97,115,101,66,97,108,97,110,99,101,40,102,114,111,109,44,97,109,111,117,110,116,41,44,116,104,105,115,46,35,105,110,99,114,101,97,115,101,66,97,108,97,110,99,101,40,116,111,44,97,109,111,117,110,116,41,125,125,123,99,111,110,115,116,114,117,99,116,111,114,40,115,116,97,116,101,41,123,115,117,112,101,114,40,92,34,65,114,116,79,110,108,105,110,101,92,34,44,92,34,65,82,84,92,34,44,49,56,44,115,116,97,116,101,41,125,125,59,34,44,34,99,111,110,115,116,114,117,99,116,111,114,80,97,114,97,109,101,116,101,114,115,34,58,91,93,125",y="237,198,141,3,123,34,99,114,101,97,116,111,114,34,58,34,56,71,85,107,103,52,120,87,113,109,110,83,56,75,101,122,56,107,54,68,115,82,120,90,66,68,97,54,114,71,74,109,104,107,122,67,75,113,78,75,102,85,110,103,90,122,109,54,97,81,34,44,34,99,111,110,116,114,97,99,116,34,58,34,114,101,116,117,114,110,32,99,108,97,115,115,32,78,97,109,101,83,101,114,118,105,99,101,123,35,110,97,109,101,61,92,34,65,114,116,79,110,108,105,110,101,78,97,109,101,83,101,114,118,105,99,101,92,34,59,35,111,119,110,101,114,59,35,112,114,105,99,101,61,48,59,35,114,101,103,105,115,116,114,121,61,123,125,59,35,99,117,114,114,101,110,99,121,59,103,101,116,32,110,97,109,101,40,41,123,114,101,116,117,114,110,32,116,104,105,115,46,35,110,97,109,101,125,103,101,116,32,114,101,103,105,115,116,114,121,40,41,123,114,101,116,117,114,110,123,46,46,46,116,104,105,115,46,35,114,101,103,105,115,116,114,121,125,125,103,101,116,32,115,116,97,116,101,40,41,123,125,99,111,110,115,116,114,117,99,116,111,114,40,102,97,99,116,111,114,121,65,100,100,114,101,115,115,44,99,117,114,114,101,110,99,121,44,118,97,108,105,100,97,116,111,114,65,100,100,114,101,115,115,44,112,114,105,99,101,44,115,116,97,116,101,41,123,115,116,97,116,101,63,40,116,104,105,115,46,35,111,119,110,101,114,61,115,116,97,116,101,46,111,119,110,101,114,44,116,104,105,115,46,35,114,101,103,105,115,116,114,121,61,115,116,97,116,101,46,114,101,103,105,115,116,114,121,44,116,104,105,115,46,35,99,117,114,114,101,110,99,121,61,115,116,97,116,101,46,99,117,114,114,101,110,99,121,44,116,104,105,115,46,35,112,114,105,99,101,61,115,116,97,116,101,46,112,114,105,99,101,41,58,40,116,104,105,115,46,35,111,119,110,101,114,61,109,115,103,46,115,101,110,100,101,114,44,116,104,105,115,46,35,112,114,105,99,101,61,112,114,105,99,101,44,116,104,105,115,46,35,114,101,103,105,115,116,114,121,46,65,114,116,79,110,108,105,110,101,67,111,110,116,114,97,99,116,70,97,99,116,111,114,121,61,123,111,119,110,101,114,58,109,115,103,46,115,101,110,100,101,114,44,97,100,100,114,101,115,115,58,102,97,99,116,111,114,121,65,100,100,114,101,115,115,125,44,116,104,105,115,46,35,114,101,103,105,115,116,114,121,46,65,114,116,79,110,108,105,110,101,84,111,107,101,110,61,123,111,119,110,101,114,58,109,115,103,46,115,101,110,100,101,114,44,97,100,100,114,101,115,115,58,99,117,114,114,101,110,99,121,125,44,116,104,105,115,46,35,114,101,103,105,115,116,114,121,46,65,114,116,79,110,108,105,110,101,86,97,108,105,100,97,116,111,114,115,61,123,111,119,110,101,114,58,109,115,103,46,115,101,110,100,101,114,44,97,100,100,114,101,115,115,58,118,97,108,105,100,97,116,111,114,65,100,100,114,101,115,115,125,44,116,104,105,115,46,35,99,117,114,114,101,110,99,121,61,99,117,114,114,101,110,99,121,41,125,99,104,97,110,103,101,79,119,110,101,114,40,111,119,110,101,114,41,123,105,102,40,109,115,103,46,115,101,110,100,101,114,33,61,61,116,104,105,115,46,35,111,119,110,101,114,41,116,104,114,111,119,32,110,101,119,32,69,114,114,111,114,40,92,34,110,111,32,111,119,110,101,114,92,34,41,59,116,104,105,115,46,35,111,119,110,101,114,61,111,119,110,101,114,125,99,104,97,110,103,101,80,114,105,99,101,40,112,114,105,99,101,41,123,105,102,40,109,115,103,46,115,101,110,100,101,114,33,61,61,116,104,105,115,46,35,111,119,110,101,114,41,116,104,114,111,119,32,110,101,119,32,69,114,114,111,114,40,92,34,110,111,32,111,119,110,101,114,92,34,41,59,116,104,105,115,46,35,112,114,105,99,101,61,112,114,105,99,101,125,99,104,97,110,103,101,67,117,114,114,101,110,99,121,40,99,117,114,114,101,110,99,121,41,123,105,102,40,109,115,103,46,115,101,110,100,101,114,33,61,61,116,104,105,115,46,35,111,119,110,101,114,41,116,104,114,111,119,32,110,101,119,32,69,114,114,111,114,40,92,34,110,111,32,111,119,110,101,114,92,34,41,59,116,104,105,115,46,35,99,117,114,114,101,110,99,121,61,99,117,114,114,101,110,99,121,125,97,115,121,110,99,32,112,117,114,99,104,97,115,101,78,97,109,101,40,110,97,109,101,44,97,100,100,114,101,115,115,41,123,105,102,40,97,119,97,105,116,32,109,115,103,46,99,97,108,108,40,116,104,105,115,46,35,99,117,114,114,101,110,99,121,44,92,34,98,97,108,97,110,99,101,79,102,92,34,44,91,109,115,103,46,115,101,110,100,101,114,93,41,60,116,104,105,115,46,35,112,114,105,99,101,41,116,104,114,111,119,32,110,101,119,32,69,114,114,111,114,40,92,34,112,114,105,99,101,32,101,120,99,101,101,100,115,32,98,97,108,97,110,99,101,92,34,41,59,116,114,121,123,97,119,97,105,116,32,109,115,103,46,99,97,108,108,40,116,104,105,115,46,35,99,117,114,114,101,110,99,121,44,92,34,116,114,97,110,115,102,101,114,92,34,44,91,109,115,103,46,115,101,110,100,101,114,44,116,104,105,115,46,35,111,119,110,101,114,44,116,104,105,115,46,35,112,114,105,99,101,93,41,125,99,97,116,99,104,40,101,41,123,116,104,114,111,119,32,101,125,116,104,105,115,46,35,114,101,103,105,115,116,114,121,91,110,97,109,101,93,61,123,111,119,110,101,114,58,109,115,103,46,115,101,110,100,101,114,44,97,100,100,114,101,115,115,125,125,108,111,111,107,117,112,40,110,97,109,101,41,123,114,101,116,117,114,110,32,116,104,105,115,46,35,114,101,103,105,115,116,114,121,91,110,97,109,101,93,125,116,114,97,110,115,102,101,114,79,119,110,101,114,115,104,105,112,40,110,97,109,101,44,116,111,41,123,105,102,40,109,115,103,46,115,101,110,100,101,114,33,61,61,116,104,105,115,46,35,114,101,103,105,115,116,114,121,46,111,119,110,101,114,41,116,104,114,111,119,32,110,101,119,32,69,114,114,111,114,40,92,34,110,111,116,32,97,32,111,119,110,101,114,92,34,41,59,116,104,105,115,46,35,114,101,103,105,115,116,114,121,91,110,97,109,101,93,46,111,119,110,101,114,61,116,111,125,99,104,97,110,103,101,65,100,100,114,101,115,115,40,110,97,109,101,44,97,100,100,114,101,115,115,41,123,105,102,40,109,115,103,46,115,101,110,100,101,114,33,61,61,116,104,105,115,46,35,114,101,103,105,115,116,114,121,46,111,119,110,101,114,41,116,104,114,111,119,32,110,101,119,32,69,114,114,111,114,40,92,34,110,111,116,32,97,32,111,119,110,101,114,92,34,41,59,116,104,105,115,46,35,114,101,103,105,115,116,114,121,91,110,97,109,101,93,46,97,100,100,114,101,115,115,61,97,100,100,114,101,115,115,125,125,59,34,44,34,99,111,110,115,116,114,117,99,116,111,114,80,97,114,97,109,101,116,101,114,115,34,58,91,34,105,104,110,121,50,103,113,103,99,50,104,120,98,105,99,115,120,101,112,53,100,111,107,116,114,115,121,109,118,100,99,114,117,52,120,99,116,117,103,122,107,116,103,120,103,113,106,97,113,122,118,105,102,50,54,109,112,101,114,34,44,34,105,104,110,121,50,103,113,103,104,111,55,112,102,50,99,103,98,107,109,113,106,121,103,120,108,120,101,114,114,120,122,109,122,51,102,101,51,120,119,53,51,110,110,107,110,117,51,119,107,102,100,115,52,98,100,122,118,50,114,34,44,34,105,104,110,121,50,103,113,103,51,113,99,98,100,114,114,107,52,98,100,119,104,109,105,101,122,51,113,97,99,102,53,55,102,98,104,101,112,97,54,105,114,104,113,117,54,110,106,110,113,102,115,50,53,108,54,122,102,103,111,34,44,34,49,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,34,93,125",B="237,198,141,3,123,34,99,114,101,97,116,111,114,34,58,34,56,71,85,107,103,52,120,87,113,109,110,83,56,75,101,122,56,107,54,68,115,82,120,90,66,68,97,54,114,71,74,109,104,107,122,67,75,113,78,75,102,85,110,103,90,122,109,54,97,81,34,44,34,99,111,110,116,114,97,99,116,34,58,34,114,101,116,117,114,110,32,99,108,97,115,115,32,86,97,108,105,100,97,116,111,114,115,123,35,110,97,109,101,61,92,34,65,114,116,79,110,108,105,110,101,86,97,108,105,100,97,116,111,114,115,92,34,59,35,116,111,116,97,108,86,97,108,105,100,97,116,111,114,115,61,48,59,35,118,97,108,105,100,97,116,111,114,115,61,123,125,59,35,111,119,110,101,114,59,35,99,117,114,114,101,110,99,121,59,35,109,105,110,105,109,117,109,66,97,108,97,110,99,101,59,103,101,116,32,115,116,97,116,101,40,41,123,114,101,116,117,114,110,123,111,119,110,101,114,58,116,104,105,115,46,35,111,119,110,101,114,44,109,105,110,105,109,117,109,66,97,108,97,110,99,101,58,116,104,105,115,46,35,109,105,110,105,109,117,109,66,97,108,97,110,99,101,44,99,117,114,114,101,110,99,121,58,116,104,105,115,46,35,99,117,114,114,101,110,99,121,44,116,111,116,97,108,86,97,108,105,100,97,116,111,114,115,58,116,104,105,115,46,35,116,111,116,97,108,86,97,108,105,100,97,116,111,114,115,44,118,97,108,105,100,97,116,111,114,115,58,116,104,105,115,46,35,118,97,108,105,100,97,116,111,114,115,125,125,99,111,110,115,116,114,117,99,116,111,114,40,116,111,107,101,110,65,100,100,114,101,115,115,44,115,116,97,116,101,41,123,115,116,97,116,101,63,40,116,104,105,115,46,35,111,119,110,101,114,61,115,116,97,116,101,46,111,119,110,101,114,44,116,104,105,115,46,35,109,105,110,105,109,117,109,66,97,108,97,110,99,101,61,115,116,97,116,101,46,109,105,110,105,109,117,109,66,97,108,97,110,99,101,44,116,104,105,115,46,35,99,117,114,114,101,110,99,121,61,115,116,97,116,101,46,99,117,114,114,101,110,99,121,44,116,104,105,115,46,35,116,111,116,97,108,86,97,108,105,100,97,116,111,114,115,61,115,116,97,116,101,46,116,111,116,97,108,86,97,108,105,100,97,116,111,114,115,44,116,104,105,115,46,35,118,97,108,105,100,97,116,111,114,115,61,115,116,97,116,101,46,118,97,108,105,100,97,116,111,114,115,41,58,40,116,104,105,115,46,35,111,119,110,101,114,61,109,115,103,46,115,101,110,100,101,114,44,116,104,105,115,46,35,109,105,110,105,109,117,109,66,97,108,97,110,99,101,61,53,101,52,44,116,104,105,115,46,35,99,117,114,114,101,110,99,121,61,116,111,107,101,110,65,100,100,114,101,115,115,44,116,104,105,115,46,35,116,111,116,97,108,86,97,108,105,100,97,116,111,114,115,43,61,49,44,116,104,105,115,46,35,118,97,108,105,100,97,116,111,114,115,91,109,115,103,46,115,101,110,100,101,114,93,61,123,102,105,114,115,116,83,101,101,110,58,40,110,101,119,32,68,97,116,101,41,46,103,101,116,84,105,109,101,40,41,44,97,99,116,105,118,101,58,33,48,125,41,125,103,101,116,32,110,97,109,101,40,41,123,114,101,116,117,114,110,32,116,104,105,115,46,35,110,97,109,101,125,103,101,116,32,111,119,110,101,114,40,41,123,114,101,116,117,114,110,32,116,104,105,115,46,35,111,119,110,101,114,125,103,101,116,32,99,117,114,114,101,110,99,121,40,41,123,114,101,116,117,114,110,32,116,104,105,115,46,35,99,117,114,114,101,110,99,121,125,103,101,116,32,118,97,108,105,100,97,116,111,114,115,40,41,123,114,101,116,117,114,110,123,46,46,46,116,104,105,115,46,35,118,97,108,105,100,97,116,111,114,115,125,125,103,101,116,32,116,111,116,97,108,86,97,108,105,100,97,116,111,114,115,40,41,123,114,101,116,117,114,110,32,116,104,105,115,46,35,116,111,116,97,108,86,97,108,105,100,97,116,111,114,115,125,103,101,116,32,109,105,110,105,109,117,109,66,97,108,97,110,99,101,40,41,123,114,101,116,117,114,110,32,116,104,105,115,46,35,109,105,110,105,109,117,109,66,97,108,97,110,99,101,125,99,104,97,110,103,101,79,119,110,101,114,40,111,119,110,101,114,41,123,105,102,40,109,115,103,46,115,101,110,100,101,114,33,61,61,116,104,105,115,46,35,111,119,110,101,114,41,116,104,114,111,119,32,110,101,119,32,69,114,114,111,114,40,92,34,110,111,116,32,97,110,32,111,119,110,101,114,92,34,41,125,99,104,97,110,103,101,67,117,114,114,101,110,99,121,40,99,117,114,114,101,110,99,121,41,123,105,102,40,109,115,103,46,115,101,110,100,101,114,33,61,61,116,104,105,115,46,35,111,119,110,101,114,41,116,104,114,111,119,32,110,101,119,32,69,114,114,111,114,40,92,34,110,111,116,32,97,110,32,111,119,110,101,114,92,34,41,59,116,104,105,115,46,35,99,117,114,114,101,110,99,121,61,99,117,114,114,101,110,99,121,125,104,97,115,40,118,97,108,105,100,97,116,111,114,41,123,114,101,116,117,114,110,32,66,111,111,108,101,97,110,40,118,111,105,100,32,48,33,61,61,116,104,105,115,46,35,118,97,108,105,100,97,116,111,114,115,91,118,97,108,105,100,97,116,111,114,93,41,125,97,115,121,110,99,32,97,100,100,86,97,108,105,100,97,116,111,114,40,118,97,108,105,100,97,116,111,114,41,123,105,102,40,116,104,105,115,46,104,97,115,40,118,97,108,105,100,97,116,111,114,41,41,116,104,114,111,119,32,110,101,119,32,69,114,114,111,114,40,92,34,97,108,114,101,97,100,121,32,97,32,118,97,108,105,100,97,116,111,114,92,34,41,59,99,111,110,115,116,32,98,97,108,97,110,99,101,61,97,119,97,105,116,32,109,115,103,46,115,116,97,116,105,99,67,97,108,108,40,116,104,105,115,46,99,117,114,114,101,110,99,121,44,92,34,98,97,108,97,110,99,101,79,102,92,34,44,91,109,115,103,46,115,101,110,100,101,114,93,41,59,105,102,40,98,97,108,97,110,99,101,60,116,104,105,115,46,109,105,110,105,109,117,109,66,97,108,97,110,99,101,41,116,104,114,111,119,32,110,101,119,32,69,114,114,111,114,40,96,98,97,108,97,110,99,101,32,116,111,32,108,111,119,33,32,103,111,116,58,32,36,123,98,97,108,97,110,99,101,125,32,110,101,101,100,58,32,36,123,116,104,105,115,46,35,109,105,110,105,109,117,109,66,97,108,97,110,99,101,125,96,41,59,116,104,105,115,46,35,116,111,116,97,108,86,97,108,105,100,97,116,111,114,115,43,61,49,44,116,104,105,115,46,35,118,97,108,105,100,97,116,111,114,115,91,118,97,108,105,100,97,116,111,114,93,61,123,102,105,114,115,116,83,101,101,110,58,40,110,101,119,32,68,97,116,101,41,46,103,101,116,84,105,109,101,40,41,44,97,99,116,105,118,101,58,33,48,125,125,114,101,109,111,118,101,86,97,108,105,100,97,116,111,114,40,118,97,108,105,100,97,116,111,114,41,123,105,102,40,33,116,104,105,115,46,104,97,115,40,118,97,108,105,100,97,116,111,114,41,41,116,104,114,111,119,32,110,101,119,32,69,114,114,111,114,40,92,34,118,97,108,105,100,97,116,111,114,32,110,111,116,32,102,111,117,110,100,92,34,41,59,116,104,105,115,46,35,116,111,116,97,108,86,97,108,105,100,97,116,111,114,115,45,61,49,44,100,101,108,101,116,101,32,116,104,105,115,46,35,118,97,108,105,100,97,116,111,114,115,91,118,97,108,105,100,97,116,111,114,93,125,97,115,121,110,99,32,117,112,100,97,116,101,86,97,108,105,100,97,116,111,114,40,118,97,108,105,100,97,116,111,114,44,97,99,116,105,118,101,41,123,105,102,40,33,116,104,105,115,46,104,97,115,40,118,97,108,105,100,97,116,111,114,41,41,116,104,114,111,119,32,110,101,119,32,69,114,114,111,114,40,92,34,118,97,108,105,100,97,116,111,114,32,110,111,116,32,102,111,117,110,100,92,34,41,59,99,111,110,115,116,32,98,97,108,97,110,99,101,61,97,119,97,105,116,32,109,115,103,46,115,116,97,116,105,99,67,97,108,108,40,116,104,105,115,46,99,117,114,114,101,110,99,121,44,92,34,98,97,108,97,110,99,101,79,102,92,34,44,91,109,115,103,46,115,101,110,100,101,114,93,41,59,105,102,40,98,97,108,97,110,99,101,60,116,104,105,115,46,109,105,110,105,109,117,109,66,97,108,97,110,99,101,38,38,116,104,105,115,46,35,118,97,108,105,100,97,116,111,114,115,91,118,97,108,105,100,97,116,111,114,93,46,97,99,116,105,118,101,38,38,40,116,104,105,115,46,35,118,97,108,105,100,97,116,111,114,115,91,118,97,108,105,100,97,116,111,114,93,46,97,99,116,105,118,101,61,33,49,41,44,98,97,108,97,110,99,101,60,116,104,105,115,46,109,105,110,105,109,117,109,66,97,108,97,110,99,101,41,116,104,114,111,119,32,110,101,119,32,69,114,114,111,114,40,96,98,97,108,97,110,99,101,32,116,111,32,108,111,119,33,32,103,111,116,58,32,36,123,98,97,108,97,110,99,101,125,32,110,101,101,100,58,32,36,123,116,104,105,115,46,35,109,105,110,105,109,117,109,66,97,108,97,110,99,101,125,96,41,59,116,104,105,115,46,35,118,97,108,105,100,97,116,111,114,115,91,118,97,108,105,100,97,116,111,114,93,46,97,99,116,105,118,101,61,97,99,116,105,118,101,125,125,59,34,44,34,99,111,110,115,116,114,117,99,116,111,114,80,97,114,97,109,101,116,101,114,115,34,58,91,34,105,104,110,121,50,103,113,103,104,111,55,112,102,50,99,103,98,107,109,113,106,121,103,120,108,120,101,114,114,120,122,109,122,51,102,101,51,120,119,53,51,110,110,107,110,117,51,119,107,102,100,115,52,98,100,122,118,50,114,34,93,125";const v=new o.default,x=w,M=N,E=y,k=B;globalThis.BigNumber=BigNumber,globalThis.peernet=globalThis.peernet||{},globalThis.contracts={};const T=(e,t,r)=>{let s;return s=r?.length>0?contracts[e][t](...r):contracts[e][t],s},q=async e=>{const t=e.decoded.constructorParameters;try{const r=new Function(e.decoded.contract)();globalThis.msg=P(e.decoded.creator),contracts[await e.hash]=await new r(...t),v.postMessage({type:"debug",messages:[`loaded contract: ${await e.hash}`,`size: ${f(e.encoded.length)}`]})}catch(t){console.log(t),v.postMessage({type:"contractError",hash:await e.hash})}},S=async(e,t,r)=>{try{let s;return s=contracts[e].fallback?await contracts[e].fallback(t,r):await contracts[e][t](...r),s}catch(e){throw e}},P=(e=globalThis.peerid)=>({sender:e,call:S,staticCall:T}),_=async e=>{const t=e.id;if("init"===e.type)try{await(async({contracts:e,blocks:t,peerid:r})=>{globalThis.peernet.codecs={"contract-message":{codec:parseInt("63636d",16),hashAlg:"keccak-256"},"transaction-message":{codec:parseInt("746d",16),hashAlg:"keccak-256"},"block-message":{codec:parseInt("626d",16),hashAlg:"keccak-256"}},globalThis.peerid=r,e=[x,M,E,k],e=await Promise.all(e.map((async e=>(e=await new ContractMessage(new Uint8Array(e.split(","))),await q(e),e))));let s={hash:"0x0"};if(t?.length>0){const e=await new o.default("./block-worker.js",{serialization:"advanced",type:"module"});t=await e.once(t);for(const e of t)await Promise.all(e.decoded.transactions.map((async e=>{const{from:t,to:r,method:s,params:n}=e;globalThis.msg=P(t),await S(r,s,n)})));t.length>0&&(s=t[t.length-1].decoded,s=await new BlockMessage(s),s={...s.decoded,hash:await s.hash})}v.postMessage({type:"machine-ready",lastBlock:s}),_worker.terminate(),v.postMessage(t)})(e.input)}catch(e){v.postMessage({type:"initError",message:e.message,id:t})}if("get"===e.type)try{const r=await T(e.input.contract,e.input.method,e.input.params);v.postMessage({type:"response",id:t,value:r})}catch(e){v.postMessage({type:"fetchError",message:e.message,id:t})}if("execute"===e.type)try{const r=await S(e.input.contract,e.input.method,e.input.params);v.postMessage({type:"response",id:t,value:r})}catch(e){v.postMessage({type:"executionError",message:e.message,id:t})}};v.onmessage((e=>_(e)));
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@leofcoin/codec-format-interface"),t=require("bn.js"),r=require("@ethersproject/bytes"),s=require("@ethersproject/logger");require("@ethersproject/bignumber"),require("path");var n=require("@vandeurenglenn/easy-worker");function i(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var a=i(t),o=i(n);class ContractMessage extends e.FormatInterface{get keys(){return["creator","contract","constructorParameters"]}get messageName(){return"ContractMessage"}constructor(e){super(e,"\nmessage ContractMessage {\n required string creator = 1;\n required bytes contract = 2;\n repeated string constructorParameters = 3;\n}\n",{name:"contract-message"})}}class BlockMessage extends e.FormatInterface{get keys(){return["index","previousHash","timestamp","reward","fees","transactions","validators"]}get messageName(){return"BlockMessage"}constructor(e){super(e,"\nmessage ValidatorMessage {\n required string address = 1;\n required string reward = 2;\n}\n\nmessage Transaction {\n required string hash = 1;\n required uint64 timestamp = 2;\n required string from = 3;\n required string to = 4;\n required uint64 nonce = 5;\n required string method = 6;\n repeated string params = 7;\n}\n\nmessage BlockMessage {\n required uint64 index = 1;\n required string previousHash = 3;\n required uint64 timestamp = 4;\n required uint64 reward = 5;\n required string fees = 6;\n repeated Transaction transactions = 7;\n repeated ValidatorMessage validators = 8;\n}\n",{name:"block-message"})}}var u=a.default.BN;const g=new s.Logger("bignumber/5.6.2"),c={};let h=!1;class BigNumber{constructor(e,t){e!==c&&g.throwError("cannot call constructor directly; use BigNumber.from",s.Logger.errors.UNSUPPORTED_OPERATION,{operation:"new (BigNumber)"}),this._hex=t,this._isBigNumber=!0,Object.freeze(this)}fromTwos(e){return d(m(this).fromTwos(e))}toTwos(e){return d(m(this).toTwos(e))}abs(){return"-"===this._hex[0]?BigNumber.from(this._hex.substring(1)):this}add(e){return d(m(this).add(m(e)))}sub(e){return d(m(this).sub(m(e)))}div(e){return BigNumber.from(e).isZero()&&p("division-by-zero","div"),d(m(this).div(m(e)))}mul(e){return d(m(this).mul(m(e)))}mod(e){const t=m(e);return t.isNeg()&&p("division-by-zero","mod"),d(m(this).umod(t))}pow(e){const t=m(e);return t.isNeg()&&p("negative-power","pow"),d(m(this).pow(t))}and(e){const t=m(e);return(this.isNegative()||t.isNeg())&&p("unbound-bitwise-result","and"),d(m(this).and(t))}or(e){const t=m(e);return(this.isNegative()||t.isNeg())&&p("unbound-bitwise-result","or"),d(m(this).or(t))}xor(e){const t=m(e);return(this.isNegative()||t.isNeg())&&p("unbound-bitwise-result","xor"),d(m(this).xor(t))}mask(e){return(this.isNegative()||e<0)&&p("negative-width","mask"),d(m(this).maskn(e))}shl(e){return(this.isNegative()||e<0)&&p("negative-width","shl"),d(m(this).shln(e))}shr(e){return(this.isNegative()||e<0)&&p("negative-width","shr"),d(m(this).shrn(e))}eq(e){return m(this).eq(m(e))}lt(e){return m(this).lt(m(e))}lte(e){return m(this).lte(m(e))}gt(e){return m(this).gt(m(e))}gte(e){return m(this).gte(m(e))}isNegative(){return"-"===this._hex[0]}isZero(){return m(this).isZero()}toNumber(){try{return m(this).toNumber()}catch(e){p("overflow","toNumber",this.toString())}return null}toBigInt(){try{return BigInt(this.toString())}catch(e){}return g.throwError("this platform does not support BigInt",s.Logger.errors.UNSUPPORTED_OPERATION,{value:this.toString()})}toString(){return arguments.length>0&&(10===arguments[0]?h||(h=!0,g.warn("BigNumber.toString does not accept any parameters; base-10 is assumed")):16===arguments[0]?g.throwError("BigNumber.toString does not accept any parameters; use bigNumber.toHexString()",s.Logger.errors.UNEXPECTED_ARGUMENT,{}):g.throwError("BigNumber.toString does not accept parameters",s.Logger.errors.UNEXPECTED_ARGUMENT,{})),m(this).toString(10)}toHexString(){return this._hex}toJSON(e){return{type:"BigNumber",hex:this.toHexString()}}static from(e){if(e instanceof BigNumber)return e;if("string"==typeof e)return e.match(/^-?0x[0-9a-f]+$/i)?new BigNumber(c,l(e)):e.match(/^-?[0-9]+$/)?new BigNumber(c,l(new u(e))):g.throwArgumentError("invalid BigNumber string","value",e);if("number"==typeof e)return e%1&&p("underflow","BigNumber.from",e),(e>=9007199254740991||e<=-9007199254740991)&&p("overflow","BigNumber.from",e),BigNumber.from(String(e));const t=e;if("bigint"==typeof t)return BigNumber.from(t.toString());if(r.isBytes(t))return BigNumber.from(r.hexlify(t));if(t)if(t.toHexString){const e=t.toHexString();if("string"==typeof e)return BigNumber.from(e)}else{let e=t._hex;if(null==e&&"BigNumber"===t.type&&(e=t.hex),"string"==typeof e&&(r.isHexString(e)||"-"===e[0]&&r.isHexString(e.substring(1))))return BigNumber.from(e)}return g.throwArgumentError("invalid BigNumber value","value",e)}static isBigNumber(e){return!(!e||!e._isBigNumber)}}function l(e){if("string"!=typeof e)return l(e.toString(16));if("-"===e[0])return"-"===(e=e.substring(1))[0]&&g.throwArgumentError("invalid hex","value",e),"0x00"===(e=l(e))?e:"-"+e;if("0x"!==e.substring(0,2)&&(e="0x"+e),"0x"===e)return"0x00";for(e.length%2&&(e="0x0"+e.substring(2));e.length>4&&"0x00"===e.substring(0,4);)e="0x"+e.substring(4);return e}function d(e){return BigNumber.from(l(e))}function m(e){const t=BigNumber.from(e).toHexString();return"-"===t[0]?new u("-"+t.substring(3),16):new u(t.substring(2),16)}function p(e,t,r){const n={fault:e,operation:t};return null!=r&&(n.value=r),g.throwError(e,s.Logger.errors.NUMERIC_FAULT,n)}new s.Logger("units/5.6.1");const b=["Bytes","KB","MB","GB","TB","PB","EB","ZB","YB"],f=(e,t=2)=>{if(0===e)return"0 Bytes";t<0&&(t=0);const r=Math.floor(Math.log(e)/Math.log(1024));return`${parseFloat((e/Math.pow(1024,r)).toFixed(t))} ${b[r]}`};var w="237,198,141,3,123,34,99,114,101,97,116,111,114,34,58,34,56,71,85,107,103,52,120,87,113,109,110,83,56,75,101,122,56,107,54,68,115,82,120,90,66,68,97,54,114,71,74,109,104,107,122,67,75,113,78,75,102,85,110,103,90,122,109,54,97,81,34,44,34,99,111,110,116,114,97,99,116,34,58,34,114,101,116,117,114,110,32,99,108,97,115,115,32,70,97,99,116,111,114,121,123,35,110,97,109,101,61,92,34,65,114,116,79,110,108,105,110,101,67,111,110,116,114,97,99,116,70,97,99,116,111,114,121,92,34,59,35,116,111,116,97,108,67,111,110,116,114,97,99,116,115,61,48,59,35,99,111,110,116,114,97,99,116,115,61,91,93,59,99,111,110,115,116,114,117,99,116,111,114,40,115,116,97,116,101,41,123,115,116,97,116,101,38,38,40,116,104,105,115,46,35,99,111,110,116,114,97,99,116,115,61,115,116,97,116,101,46,99,111,110,116,114,97,99,116,115,44,116,104,105,115,46,35,116,111,116,97,108,67,111,110,116,114,97,99,116,115,61,115,116,97,116,101,46,116,111,116,97,108,67,111,110,116,114,97,99,116,115,41,125,103,101,116,32,115,116,97,116,101,40,41,123,114,101,116,117,114,110,123,116,111,116,97,108,67,111,110,116,114,97,99,116,115,58,116,104,105,115,46,35,116,111,116,97,108,67,111,110,116,114,97,99,116,115,44,99,111,110,116,114,97,99,116,115,58,116,104,105,115,46,35,99,111,110,116,114,97,99,116,115,125,125,103,101,116,32,110,97,109,101,40,41,123,114,101,116,117,114,110,32,116,104,105,115,46,35,110,97,109,101,125,103,101,116,32,99,111,110,116,114,97,99,116,115,40,41,123,114,101,116,117,114,110,91,46,46,46,116,104,105,115,46,35,99,111,110,116,114,97,99,116,115,93,125,103,101,116,32,116,111,116,97,108,67,111,110,116,114,97,99,116,115,40,41,123,114,101,116,117,114,110,32,116,104,105,115,46,35,116,111,116,97,108,67,111,110,116,114,97,99,116,115,125,105,115,118,97,108,105,100,40,104,97,115,104,44,99,114,101,97,116,111,114,44,99,111,110,116,114,97,99,116,44,99,111,110,115,116,114,117,99,116,111,114,80,97,114,97,109,101,116,101,114,115,61,91,93,41,123,99,111,110,115,116,32,109,101,115,115,97,103,101,61,110,101,119,32,67,111,110,116,114,97,99,116,77,101,115,115,97,103,101,40,123,99,114,101,97,116,111,114,44,99,111,110,116,114,97,99,116,44,99,111,110,115,116,114,117,99,116,111,114,80,97,114,97,109,101,116,101,114,115,125,41,59,114,101,116,117,114,110,32,66,111,111,108,101,97,110,40,109,101,115,115,97,103,101,46,104,97,115,104,61,61,61,104,97,115,104,41,125,97,115,121,110,99,32,100,101,112,108,111,121,67,111,110,116,114,97,99,116,40,99,111,110,116,114,97,99,116,72,97,115,104,44,99,114,101,97,116,111,114,44,99,111,110,116,114,97,99,116,44,99,111,110,115,116,114,117,99,116,111,114,80,97,114,97,109,101,116,101,114,115,61,91,93,41,123,105,102,40,99,111,110,116,114,97,99,116,46,99,114,101,97,116,111,114,33,61,61,109,115,103,46,115,101,110,100,101,114,41,116,104,114,111,119,32,110,101,119,32,69,114,114,111,114,40,92,34,111,110,108,121,32,97,32,99,111,110,116,114,97,99,116,32,99,114,101,97,116,111,114,32,99,97,110,32,100,101,112,108,111,121,32,97,32,99,111,110,116,114,97,99,116,92,34,41,59,105,102,40,97,119,97,105,116,32,99,111,110,116,114,97,99,116,83,116,111,114,101,46,104,97,115,40,104,97,115,104,41,41,116,104,114,111,119,32,110,101,119,32,69,114,114,111,114,40,92,34,100,117,112,108,105,99,97,116,101,32,99,111,110,116,114,97,99,116,92,34,41,59,105,102,40,33,116,104,105,115,46,105,115,86,97,108,105,100,40,99,111,110,116,114,97,99,116,72,97,115,104,44,99,114,101,97,116,111,114,44,99,111,110,116,114,97,99,116,44,99,111,110,115,116,114,117,99,116,111,114,80,97,114,97,109,101,116,101,114,115,41,41,116,104,114,111,119,32,110,101,119,32,69,114,114,111,114,40,92,34,105,110,118,97,108,105,100,32,99,111,110,116,114,97,99,116,92,34,41,59,97,119,97,105,116,32,99,111,110,116,114,97,99,116,83,116,111,114,101,46,112,117,116,40,104,97,115,104,44,101,110,99,111,100,101,100,41,44,116,104,105,115,46,35,116,111,116,97,108,67,111,110,116,114,97,99,116,115,43,61,49,44,116,104,105,115,46,35,99,111,110,116,114,97,99,116,115,46,112,117,115,104,40,104,97,115,104,41,125,125,59,34,44,34,99,111,110,115,116,114,117,99,116,111,114,80,97,114,97,109,101,116,101,114,115,34,58,91,93,125",N="237,198,141,3,123,34,99,114,101,97,116,111,114,34,58,34,56,71,85,107,103,52,120,87,113,109,110,83,56,75,101,122,56,107,54,68,115,82,120,90,66,68,97,54,114,71,74,109,104,107,122,67,75,113,78,75,102,85,110,103,90,122,109,54,97,81,34,44,34,99,111,110,116,114,97,99,116,34,58,34,114,101,116,117,114,110,32,99,108,97,115,115,32,65,114,116,79,110,108,105,110,101,32,101,120,116,101,110,100,115,32,99,108,97,115,115,32,84,111,107,101,110,32,101,120,116,101,110,100,115,32,99,108,97,115,115,32,82,111,108,101,115,123,35,114,111,108,101,115,61,123,79,87,78,69,82,58,91,93,44,77,73,78,84,58,91,93,44,66,85,82,78,58,91,93,125,59,99,111,110,115,116,114,117,99,116,111,114,40,114,111,108,101,115,41,123,105,102,40,114,111,108,101,115,41,123,105,102,40,33,40,114,111,108,101,115,32,105,110,115,116,97,110,99,101,111,102,32,79,98,106,101,99,116,41,41,116,104,114,111,119,32,110,101,119,32,69,114,114,111,114,40,92,34,101,120,112,101,99,116,101,100,32,114,111,108,101,115,32,116,111,32,98,101,32,97,110,32,111,98,106,101,99,116,92,34,41,59,116,104,105,115,46,35,114,111,108,101,115,61,123,46,46,46,114,111,108,101,115,44,46,46,46,116,104,105,115,46,35,114,111,108,101,115,125,125,101,108,115,101,32,116,104,105,115,46,35,103,114,97,110,116,82,111,108,101,40,109,115,103,46,115,101,110,100,101,114,44,92,34,79,87,78,69,82,92,34,41,125,103,101,116,32,115,116,97,116,101,40,41,123,114,101,116,117,114,110,123,114,111,108,101,115,58,116,104,105,115,46,114,111,108,101,115,125,125,103,101,116,32,114,111,108,101,115,40,41,123,114,101,116,117,114,110,123,46,46,46,116,104,105,115,46,35,114,111,108,101,115,125,125,104,97,115,82,111,108,101,40,97,100,100,114,101,115,115,44,114,111,108,101,41,123,114,101,116,117,114,110,33,33,116,104,105,115,46,35,114,111,108,101,115,91,114,111,108,101,93,38,38,45,49,33,61,61,116,104,105,115,46,35,114,111,108,101,115,91,114,111,108,101,93,46,105,110,100,101,120,79,102,40,97,100,100,114,101,115,115,41,125,35,103,114,97,110,116,82,111,108,101,40,97,100,100,114,101,115,115,44,114,111,108,101,41,123,105,102,40,116,104,105,115,46,104,97,115,82,111,108,101,40,97,100,100,114,101,115,115,44,114,111,108,101,41,41,116,104,114,111,119,32,110,101,119,32,69,114,114,111,114,40,96,36,123,114,111,108,101,125,32,114,111,108,101,32,97,108,114,101,97,100,121,32,103,114,97,110,116,101,100,32,102,111,114,32,36,123,97,100,100,114,101,115,115,125,96,41,59,116,104,105,115,46,35,114,111,108,101,115,91,114,111,108,101,93,46,112,117,115,104,40,97,100,100,114,101,115,115,41,125,35,114,101,118,111,107,101,82,111,108,101,40,97,100,100,114,101,115,115,44,114,111,108,101,41,123,105,102,40,33,116,104,105,115,46,104,97,115,82,111,108,101,40,97,100,100,114,101,115,115,44,114,111,108,101,41,41,116,104,114,111,119,32,110,101,119,32,69,114,114,111,114,40,96,36,123,114,111,108,101,125,32,114,111,108,101,32,97,108,114,101,97,100,121,32,114,101,118,111,107,101,100,32,102,111,114,32,36,123,97,100,100,114,101,115,115,125,96,41,59,105,102,40,92,34,79,87,78,69,82,92,34,61,61,61,114,111,108,101,38,38,49,61,61,61,116,104,105,115,46,35,114,111,108,101,115,91,114,111,108,101,93,46,108,101,110,103,116,104,41,116,104,114,111,119,32,110,101,119,32,69,114,114,111,114,40,92,34,97,116,108,101,97,115,116,32,111,110,101,32,111,119,110,101,114,32,105,115,32,110,101,101,100,101,100,33,92,34,41,59,116,104,105,115,46,35,114,111,108,101,115,91,114,111,108,101,93,46,115,112,108,105,99,101,40,116,104,105,115,46,35,114,111,108,101,115,91,114,111,108,101,93,46,105,110,100,101,120,79,102,40,97,100,100,114,101,115,115,41,41,125,103,114,97,110,116,82,111,108,101,40,97,100,100,114,101,115,115,44,114,111,108,101,41,123,105,102,40,33,116,104,105,115,46,104,97,115,82,111,108,101,40,97,100,100,114,101,115,115,44,92,34,79,87,78,69,82,92,34,41,41,116,104,114,111,119,32,110,101,119,32,69,114,114,111,114,40,92,34,78,111,116,32,97,108,108,111,119,101,100,92,34,41,59,116,104,105,115,46,35,103,114,97,110,116,82,111,108,101,40,97,100,100,114,101,115,115,44,114,111,108,101,41,125,114,101,118,111,107,101,82,111,108,101,40,97,100,100,114,101,115,115,44,114,111,108,101,41,123,105,102,40,33,116,104,105,115,46,104,97,115,82,111,108,101,40,97,100,100,114,101,115,115,44,92,34,79,87,78,69,82,92,34,41,41,116,104,114,111,119,32,110,101,119,32,69,114,114,111,114,40,92,34,78,111,116,32,97,108,108,111,119,101,100,92,34,41,59,116,104,105,115,46,35,114,101,118,111,107,101,82,111,108,101,40,97,100,100,114,101,115,115,44,114,111,108,101,41,125,125,123,35,110,97,109,101,59,35,115,121,109,98,111,108,59,35,104,111,108,100,101,114,115,61,48,59,35,98,97,108,97,110,99,101,115,61,123,125,59,35,97,112,112,114,111,118,97,108,115,61,123,125,59,35,100,101,99,105,109,97,108,115,61,49,56,59,35,116,111,116,97,108,83,117,112,112,108,121,61,66,105,103,78,117,109,98,101,114,46,102,114,111,109,40,48,41,59,99,111,110,115,116,114,117,99,116,111,114,40,110,97,109,101,44,115,121,109,98,111,108,44,100,101,99,105,109,97,108,115,61,49,56,44,115,116,97,116,101,41,123,105,102,40,33,110,97,109,101,41,116,104,114,111,119,32,110,101,119,32,69,114,114,111,114,40,92,34,110,97,109,101,32,117,110,100,101,102,105,110,101,100,92,34,41,59,105,102,40,33,115,121,109,98,111,108,41,116,104,114,111,119,32,110,101,119,32,69,114,114,111,114,40,92,34,115,121,109,98,111,108,32,117,110,100,101,102,105,110,101,100,92,34,41,59,115,117,112,101,114,40,115,116,97,116,101,63,46,114,111,108,101,115,41,44,116,104,105,115,46,35,110,97,109,101,61,110,97,109,101,44,116,104,105,115,46,35,115,121,109,98,111,108,61,115,121,109,98,111,108,44,116,104,105,115,46,35,100,101,99,105,109,97,108,115,61,100,101,99,105,109,97,108,115,125,103,101,116,32,115,116,97,116,101,40,41,123,114,101,116,117,114,110,123,46,46,46,115,117,112,101,114,46,115,116,97,116,101,44,104,111,108,100,101,114,115,58,116,104,105,115,46,104,111,108,100,101,114,115,44,98,97,108,97,110,99,101,115,58,116,104,105,115,46,98,97,108,97,110,99,101,115,44,97,112,112,114,111,118,97,108,115,58,123,46,46,46,116,104,105,115,46,35,97,112,112,114,111,118,97,108,115,125,44,116,111,116,97,108,83,117,112,112,108,121,58,116,104,105,115,46,116,111,116,97,108,83,117,112,112,108,121,125,125,103,101,116,32,116,111,116,97,108,83,117,112,112,108,121,40,41,123,114,101,116,117,114,110,32,116,104,105,115,46,35,116,111,116,97,108,83,117,112,112,108,121,125,103,101,116,32,110,97,109,101,40,41,123,114,101,116,117,114,110,32,116,104,105,115,46,35,110,97,109,101,125,103,101,116,32,115,121,109,98,111,108,40,41,123,114,101,116,117,114,110,32,116,104,105,115,46,35,115,121,109,98,111,108,125,103,101,116,32,104,111,108,100,101,114,115,40,41,123,114,101,116,117,114,110,32,116,104,105,115,46,35,104,111,108,100,101,114,115,125,103,101,116,32,98,97,108,97,110,99,101,115,40,41,123,114,101,116,117,114,110,123,46,46,46,116,104,105,115,46,35,98,97,108,97,110,99,101,115,125,125,109,105,110,116,40,116,111,44,97,109,111,117,110,116,41,123,105,102,40,33,116,104,105,115,46,104,97,115,82,111,108,101,40,109,115,103,46,115,101,110,100,101,114,44,92,34,77,73,78,84,92,34,41,41,116,104,114,111,119,32,110,101,119,32,69,114,114,111,114,40,92,34,110,111,116,32,97,108,108,111,119,101,100,92,34,41,59,116,104,105,115,46,35,116,111,116,97,108,83,117,112,112,108,121,61,116,104,105,115,46,35,116,111,116,97,108,83,117,112,112,108,121,46,97,100,100,40,97,109,111,117,110,116,41,44,116,104,105,115,46,35,105,110,99,114,101,97,115,101,66,97,108,97,110,99,101,40,116,111,44,97,109,111,117,110,116,41,125,98,117,114,110,40,116,111,44,97,109,111,117,110,116,41,123,105,102,40,33,116,104,105,115,46,104,97,115,82,111,108,101,40,109,115,103,46,115,101,110,100,101,114,44,92,34,66,85,82,78,92,34,41,41,116,104,114,111,119,32,110,101,119,32,69,114,114,111,114,40,92,34,110,111,116,32,97,108,108,111,119,101,100,92,34,41,59,116,104,105,115,46,35,116,111,116,97,108,83,117,112,112,108,121,61,116,104,105,115,46,35,116,111,116,97,108,83,117,112,112,108,121,46,115,117,98,40,97,109,111,117,110,116,41,44,116,104,105,115,46,35,100,101,99,114,101,97,115,101,66,97,108,97,110,99,101,40,116,111,44,97,109,111,117,110,116,41,125,35,98,101,102,111,114,101,84,114,97,110,115,102,101,114,40,102,114,111,109,44,116,111,44,97,109,111,117,110,116,41,123,105,102,40,33,116,104,105,115,46,35,98,97,108,97,110,99,101,115,91,102,114,111,109,93,124,124,116,104,105,115,46,35,98,97,108,97,110,99,101,115,91,102,114,111,109,93,60,97,109,111,117,110,116,41,116,104,114,111,119,32,110,101,119,32,69,114,114,111,114,40,92,34,97,109,111,117,110,116,32,101,120,99,101,101,100,115,32,98,97,108,97,110,99,101,92,34,41,125,35,117,112,100,97,116,101,72,111,108,100,101,114,115,40,97,100,100,114,101,115,115,44,112,114,101,118,105,111,117,115,66,97,108,97,110,99,101,41,123,92,34,48,120,48,48,92,34,61,61,61,116,104,105,115,46,35,98,97,108,97,110,99,101,115,91,97,100,100,114,101,115,115,93,46,116,111,72,101,120,83,116,114,105,110,103,40,41,63,116,104,105,115,46,35,104,111,108,100,101,114,115,45,61,49,58,92,34,48,120,48,48,92,34,33,61,61,116,104,105,115,46,35,98,97,108,97,110,99,101,115,91,97,100,100,114,101,115,115,93,46,116,111,72,101,120,83,116,114,105,110,103,40,41,38,38,92,34,48,120,48,48,92,34,61,61,61,112,114,101,118,105,111,117,115,66,97,108,97,110,99,101,46,116,111,72,101,120,83,116,114,105,110,103,40,41,38,38,40,116,104,105,115,46,35,104,111,108,100,101,114,115,43,61,49,41,125,35,105,110,99,114,101,97,115,101,66,97,108,97,110,99,101,40,97,100,100,114,101,115,115,44,97,109,111,117,110,116,41,123,116,104,105,115,46,35,98,97,108,97,110,99,101,115,91,97,100,100,114,101,115,115,93,124,124,40,116,104,105,115,46,35,98,97,108,97,110,99,101,115,91,97,100,100,114,101,115,115,93,61,66,105,103,78,117,109,98,101,114,46,102,114,111,109,40,48,41,41,59,99,111,110,115,116,32,112,114,101,118,105,111,117,115,66,97,108,97,110,99,101,61,116,104,105,115,46,35,98,97,108,97,110,99,101,115,91,97,100,100,114,101,115,115,93,59,116,104,105,115,46,35,98,97,108,97,110,99,101,115,91,97,100,100,114,101,115,115,93,61,116,104,105,115,46,35,98,97,108,97,110,99,101,115,91,97,100,100,114,101,115,115,93,46,97,100,100,40,97,109,111,117,110,116,41,44,116,104,105,115,46,35,117,112,100,97,116,101,72,111,108,100,101,114,115,40,97,100,100,114,101,115,115,44,112,114,101,118,105,111,117,115,66,97,108,97,110,99,101,41,125,35,100,101,99,114,101,97,115,101,66,97,108,97,110,99,101,40,97,100,100,114,101,115,115,44,97,109,111,117,110,116,41,123,99,111,110,115,116,32,112,114,101,118,105,111,117,115,66,97,108,97,110,99,101,61,116,104,105,115,46,35,98,97,108,97,110,99,101,115,91,97,100,100,114,101,115,115,93,59,116,104,105,115,46,35,98,97,108,97,110,99,101,115,91,97,100,100,114,101,115,115,93,61,116,104,105,115,46,35,98,97,108,97,110,99,101,115,91,97,100,100,114,101,115,115,93,46,115,117,98,40,97,109,111,117,110,116,41,44,116,104,105,115,46,35,117,112,100,97,116,101,72,111,108,100,101,114,115,40,97,100,100,114,101,115,115,44,112,114,101,118,105,111,117,115,66,97,108,97,110,99,101,41,125,98,97,108,97,110,99,101,79,102,40,97,100,100,114,101,115,115,41,123,114,101,116,117,114,110,32,116,104,105,115,46,35,98,97,108,97,110,99,101,115,91,97,100,100,114,101,115,115,93,125,115,101,116,65,112,112,114,111,118,97,108,40,111,112,101,114,97,116,111,114,44,97,109,111,117,110,116,41,123,99,111,110,115,116,32,111,119,110,101,114,61,103,108,111,98,97,108,84,104,105,115,46,109,115,103,46,115,101,110,100,101,114,59,116,104,105,115,46,35,97,112,112,114,111,118,97,108,115,91,111,119,110,101,114,93,124,124,40,116,104,105,115,46,35,97,112,112,114,111,118,97,108,115,91,111,119,110,101,114,93,61,123,125,41,44,116,104,105,115,46,35,97,112,112,114,111,118,97,108,115,91,111,119,110,101,114,93,91,111,112,101,114,97,116,111,114,93,61,97,109,111,117,110,116,125,97,112,112,114,111,118,101,100,40,111,119,110,101,114,44,111,112,101,114,97,116,111,114,44,97,109,111,117,110,116,41,123,114,101,116,117,114,110,32,116,104,105,115,46,35,97,112,112,114,111,118,97,108,115,91,111,119,110,101,114,93,91,111,112,101,114,97,116,111,114,93,61,61,61,97,109,111,117,110,116,125,116,114,97,110,115,102,101,114,40,102,114,111,109,44,116,111,44,97,109,111,117,110,116,41,123,97,109,111,117,110,116,61,66,105,103,78,117,109,98,101,114,46,102,114,111,109,40,97,109,111,117,110,116,41,44,116,104,105,115,46,35,98,101,102,111,114,101,84,114,97,110,115,102,101,114,40,102,114,111,109,44,116,111,44,97,109,111,117,110,116,41,44,116,104,105,115,46,35,100,101,99,114,101,97,115,101,66,97,108,97,110,99,101,40,102,114,111,109,44,97,109,111,117,110,116,41,44,116,104,105,115,46,35,105,110,99,114,101,97,115,101,66,97,108,97,110,99,101,40,116,111,44,97,109,111,117,110,116,41,125,125,123,99,111,110,115,116,114,117,99,116,111,114,40,115,116,97,116,101,41,123,115,117,112,101,114,40,92,34,65,114,116,79,110,108,105,110,101,92,34,44,92,34,65,82,84,92,34,44,49,56,44,115,116,97,116,101,41,125,125,59,34,44,34,99,111,110,115,116,114,117,99,116,111,114,80,97,114,97,109,101,116,101,114,115,34,58,91,93,125",y="237,198,141,3,123,34,99,114,101,97,116,111,114,34,58,34,56,71,85,107,103,52,120,87,113,109,110,83,56,75,101,122,56,107,54,68,115,82,120,90,66,68,97,54,114,71,74,109,104,107,122,67,75,113,78,75,102,85,110,103,90,122,109,54,97,81,34,44,34,99,111,110,116,114,97,99,116,34,58,34,114,101,116,117,114,110,32,99,108,97,115,115,32,78,97,109,101,83,101,114,118,105,99,101,123,35,110,97,109,101,61,92,34,65,114,116,79,110,108,105,110,101,78,97,109,101,83,101,114,118,105,99,101,92,34,59,35,111,119,110,101,114,59,35,112,114,105,99,101,61,48,59,35,114,101,103,105,115,116,114,121,61,123,125,59,35,99,117,114,114,101,110,99,121,59,103,101,116,32,110,97,109,101,40,41,123,114,101,116,117,114,110,32,116,104,105,115,46,35,110,97,109,101,125,103,101,116,32,114,101,103,105,115,116,114,121,40,41,123,114,101,116,117,114,110,123,46,46,46,116,104,105,115,46,35,114,101,103,105,115,116,114,121,125,125,103,101,116,32,115,116,97,116,101,40,41,123,125,99,111,110,115,116,114,117,99,116,111,114,40,102,97,99,116,111,114,121,65,100,100,114,101,115,115,44,99,117,114,114,101,110,99,121,44,118,97,108,105,100,97,116,111,114,65,100,100,114,101,115,115,44,112,114,105,99,101,44,115,116,97,116,101,41,123,115,116,97,116,101,63,40,116,104,105,115,46,35,111,119,110,101,114,61,115,116,97,116,101,46,111,119,110,101,114,44,116,104,105,115,46,35,114,101,103,105,115,116,114,121,61,115,116,97,116,101,46,114,101,103,105,115,116,114,121,44,116,104,105,115,46,35,99,117,114,114,101,110,99,121,61,115,116,97,116,101,46,99,117,114,114,101,110,99,121,44,116,104,105,115,46,35,112,114,105,99,101,61,115,116,97,116,101,46,112,114,105,99,101,41,58,40,116,104,105,115,46,35,111,119,110,101,114,61,109,115,103,46,115,101,110,100,101,114,44,116,104,105,115,46,35,112,114,105,99,101,61,112,114,105,99,101,44,116,104,105,115,46,35,114,101,103,105,115,116,114,121,46,65,114,116,79,110,108,105,110,101,67,111,110,116,114,97,99,116,70,97,99,116,111,114,121,61,123,111,119,110,101,114,58,109,115,103,46,115,101,110,100,101,114,44,97,100,100,114,101,115,115,58,102,97,99,116,111,114,121,65,100,100,114,101,115,115,125,44,116,104,105,115,46,35,114,101,103,105,115,116,114,121,46,65,114,116,79,110,108,105,110,101,84,111,107,101,110,61,123,111,119,110,101,114,58,109,115,103,46,115,101,110,100,101,114,44,97,100,100,114,101,115,115,58,99,117,114,114,101,110,99,121,125,44,116,104,105,115,46,35,114,101,103,105,115,116,114,121,46,65,114,116,79,110,108,105,110,101,86,97,108,105,100,97,116,111,114,115,61,123,111,119,110,101,114,58,109,115,103,46,115,101,110,100,101,114,44,97,100,100,114,101,115,115,58,118,97,108,105,100,97,116,111,114,65,100,100,114,101,115,115,125,44,116,104,105,115,46,35,99,117,114,114,101,110,99,121,61,99,117,114,114,101,110,99,121,41,125,99,104,97,110,103,101,79,119,110,101,114,40,111,119,110,101,114,41,123,105,102,40,109,115,103,46,115,101,110,100,101,114,33,61,61,116,104,105,115,46,35,111,119,110,101,114,41,116,104,114,111,119,32,110,101,119,32,69,114,114,111,114,40,92,34,110,111,32,111,119,110,101,114,92,34,41,59,116,104,105,115,46,35,111,119,110,101,114,61,111,119,110,101,114,125,99,104,97,110,103,101,80,114,105,99,101,40,112,114,105,99,101,41,123,105,102,40,109,115,103,46,115,101,110,100,101,114,33,61,61,116,104,105,115,46,35,111,119,110,101,114,41,116,104,114,111,119,32,110,101,119,32,69,114,114,111,114,40,92,34,110,111,32,111,119,110,101,114,92,34,41,59,116,104,105,115,46,35,112,114,105,99,101,61,112,114,105,99,101,125,99,104,97,110,103,101,67,117,114,114,101,110,99,121,40,99,117,114,114,101,110,99,121,41,123,105,102,40,109,115,103,46,115,101,110,100,101,114,33,61,61,116,104,105,115,46,35,111,119,110,101,114,41,116,104,114,111,119,32,110,101,119,32,69,114,114,111,114,40,92,34,110,111,32,111,119,110,101,114,92,34,41,59,116,104,105,115,46,35,99,117,114,114,101,110,99,121,61,99,117,114,114,101,110,99,121,125,97,115,121,110,99,32,112,117,114,99,104,97,115,101,78,97,109,101,40,110,97,109,101,44,97,100,100,114,101,115,115,41,123,105,102,40,97,119,97,105,116,32,109,115,103,46,99,97,108,108,40,116,104,105,115,46,35,99,117,114,114,101,110,99,121,44,92,34,98,97,108,97,110,99,101,79,102,92,34,44,91,109,115,103,46,115,101,110,100,101,114,93,41,60,116,104,105,115,46,35,112,114,105,99,101,41,116,104,114,111,119,32,110,101,119,32,69,114,114,111,114,40,92,34,112,114,105,99,101,32,101,120,99,101,101,100,115,32,98,97,108,97,110,99,101,92,34,41,59,116,114,121,123,97,119,97,105,116,32,109,115,103,46,99,97,108,108,40,116,104,105,115,46,35,99,117,114,114,101,110,99,121,44,92,34,116,114,97,110,115,102,101,114,92,34,44,91,109,115,103,46,115,101,110,100,101,114,44,116,104,105,115,46,35,111,119,110,101,114,44,116,104,105,115,46,35,112,114,105,99,101,93,41,125,99,97,116,99,104,40,101,41,123,116,104,114,111,119,32,101,125,116,104,105,115,46,35,114,101,103,105,115,116,114,121,91,110,97,109,101,93,61,123,111,119,110,101,114,58,109,115,103,46,115,101,110,100,101,114,44,97,100,100,114,101,115,115,125,125,108,111,111,107,117,112,40,110,97,109,101,41,123,114,101,116,117,114,110,32,116,104,105,115,46,35,114,101,103,105,115,116,114,121,91,110,97,109,101,93,125,116,114,97,110,115,102,101,114,79,119,110,101,114,115,104,105,112,40,110,97,109,101,44,116,111,41,123,105,102,40,109,115,103,46,115,101,110,100,101,114,33,61,61,116,104,105,115,46,35,114,101,103,105,115,116,114,121,46,111,119,110,101,114,41,116,104,114,111,119,32,110,101,119,32,69,114,114,111,114,40,92,34,110,111,116,32,97,32,111,119,110,101,114,92,34,41,59,116,104,105,115,46,35,114,101,103,105,115,116,114,121,91,110,97,109,101,93,46,111,119,110,101,114,61,116,111,125,99,104,97,110,103,101,65,100,100,114,101,115,115,40,110,97,109,101,44,97,100,100,114,101,115,115,41,123,105,102,40,109,115,103,46,115,101,110,100,101,114,33,61,61,116,104,105,115,46,35,114,101,103,105,115,116,114,121,46,111,119,110,101,114,41,116,104,114,111,119,32,110,101,119,32,69,114,114,111,114,40,92,34,110,111,116,32,97,32,111,119,110,101,114,92,34,41,59,116,104,105,115,46,35,114,101,103,105,115,116,114,121,91,110,97,109,101,93,46,97,100,100,114,101,115,115,61,97,100,100,114,101,115,115,125,125,59,34,44,34,99,111,110,115,116,114,117,99,116,111,114,80,97,114,97,109,101,116,101,114,115,34,58,91,34,105,104,110,121,50,103,113,103,99,50,104,120,98,105,99,115,120,101,112,53,100,111,107,116,114,115,121,109,118,100,99,114,117,52,120,99,116,117,103,122,107,116,103,120,103,113,106,97,113,122,118,105,102,50,54,109,112,101,114,34,44,34,105,104,110,121,50,103,113,103,104,111,55,112,102,50,99,103,98,107,109,113,106,121,103,120,108,120,101,114,114,120,122,109,122,51,102,101,51,120,119,53,51,110,110,107,110,117,51,119,107,102,100,115,52,98,100,122,118,50,114,34,44,34,105,104,110,121,50,103,113,103,51,113,99,98,100,114,114,107,52,98,100,119,104,109,105,101,122,51,113,97,99,102,53,55,102,98,104,101,112,97,54,105,114,104,113,117,54,110,106,110,113,102,115,50,53,108,54,122,102,103,111,34,44,34,49,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,34,93,125",B="237,198,141,3,123,34,99,114,101,97,116,111,114,34,58,34,56,71,85,107,103,52,120,87,113,109,110,83,56,75,101,122,56,107,54,68,115,82,120,90,66,68,97,54,114,71,74,109,104,107,122,67,75,113,78,75,102,85,110,103,90,122,109,54,97,81,34,44,34,99,111,110,116,114,97,99,116,34,58,34,114,101,116,117,114,110,32,99,108,97,115,115,32,86,97,108,105,100,97,116,111,114,115,123,35,110,97,109,101,61,92,34,65,114,116,79,110,108,105,110,101,86,97,108,105,100,97,116,111,114,115,92,34,59,35,116,111,116,97,108,86,97,108,105,100,97,116,111,114,115,61,48,59,35,118,97,108,105,100,97,116,111,114,115,61,123,125,59,35,111,119,110,101,114,59,35,99,117,114,114,101,110,99,121,59,35,109,105,110,105,109,117,109,66,97,108,97,110,99,101,59,103,101,116,32,115,116,97,116,101,40,41,123,114,101,116,117,114,110,123,111,119,110,101,114,58,116,104,105,115,46,35,111,119,110,101,114,44,109,105,110,105,109,117,109,66,97,108,97,110,99,101,58,116,104,105,115,46,35,109,105,110,105,109,117,109,66,97,108,97,110,99,101,44,99,117,114,114,101,110,99,121,58,116,104,105,115,46,35,99,117,114,114,101,110,99,121,44,116,111,116,97,108,86,97,108,105,100,97,116,111,114,115,58,116,104,105,115,46,35,116,111,116,97,108,86,97,108,105,100,97,116,111,114,115,44,118,97,108,105,100,97,116,111,114,115,58,116,104,105,115,46,35,118,97,108,105,100,97,116,111,114,115,125,125,99,111,110,115,116,114,117,99,116,111,114,40,116,111,107,101,110,65,100,100,114,101,115,115,44,115,116,97,116,101,41,123,115,116,97,116,101,63,40,116,104,105,115,46,35,111,119,110,101,114,61,115,116,97,116,101,46,111,119,110,101,114,44,116,104,105,115,46,35,109,105,110,105,109,117,109,66,97,108,97,110,99,101,61,115,116,97,116,101,46,109,105,110,105,109,117,109,66,97,108,97,110,99,101,44,116,104,105,115,46,35,99,117,114,114,101,110,99,121,61,115,116,97,116,101,46,99,117,114,114,101,110,99,121,44,116,104,105,115,46,35,116,111,116,97,108,86,97,108,105,100,97,116,111,114,115,61,115,116,97,116,101,46,116,111,116,97,108,86,97,108,105,100,97,116,111,114,115,44,116,104,105,115,46,35,118,97,108,105,100,97,116,111,114,115,61,115,116,97,116,101,46,118,97,108,105,100,97,116,111,114,115,41,58,40,116,104,105,115,46,35,111,119,110,101,114,61,109,115,103,46,115,101,110,100,101,114,44,116,104,105,115,46,35,109,105,110,105,109,117,109,66,97,108,97,110,99,101,61,53,101,52,44,116,104,105,115,46,35,99,117,114,114,101,110,99,121,61,116,111,107,101,110,65,100,100,114,101,115,115,44,116,104,105,115,46,35,116,111,116,97,108,86,97,108,105,100,97,116,111,114,115,43,61,49,44,116,104,105,115,46,35,118,97,108,105,100,97,116,111,114,115,91,109,115,103,46,115,101,110,100,101,114,93,61,123,102,105,114,115,116,83,101,101,110,58,40,110,101,119,32,68,97,116,101,41,46,103,101,116,84,105,109,101,40,41,44,97,99,116,105,118,101,58,33,48,125,41,125,103,101,116,32,110,97,109,101,40,41,123,114,101,116,117,114,110,32,116,104,105,115,46,35,110,97,109,101,125,103,101,116,32,111,119,110,101,114,40,41,123,114,101,116,117,114,110,32,116,104,105,115,46,35,111,119,110,101,114,125,103,101,116,32,99,117,114,114,101,110,99,121,40,41,123,114,101,116,117,114,110,32,116,104,105,115,46,35,99,117,114,114,101,110,99,121,125,103,101,116,32,118,97,108,105,100,97,116,111,114,115,40,41,123,114,101,116,117,114,110,123,46,46,46,116,104,105,115,46,35,118,97,108,105,100,97,116,111,114,115,125,125,103,101,116,32,116,111,116,97,108,86,97,108,105,100,97,116,111,114,115,40,41,123,114,101,116,117,114,110,32,116,104,105,115,46,35,116,111,116,97,108,86,97,108,105,100,97,116,111,114,115,125,103,101,116,32,109,105,110,105,109,117,109,66,97,108,97,110,99,101,40,41,123,114,101,116,117,114,110,32,116,104,105,115,46,35,109,105,110,105,109,117,109,66,97,108,97,110,99,101,125,99,104,97,110,103,101,79,119,110,101,114,40,111,119,110,101,114,41,123,105,102,40,109,115,103,46,115,101,110,100,101,114,33,61,61,116,104,105,115,46,35,111,119,110,101,114,41,116,104,114,111,119,32,110,101,119,32,69,114,114,111,114,40,92,34,110,111,116,32,97,110,32,111,119,110,101,114,92,34,41,125,99,104,97,110,103,101,67,117,114,114,101,110,99,121,40,99,117,114,114,101,110,99,121,41,123,105,102,40,109,115,103,46,115,101,110,100,101,114,33,61,61,116,104,105,115,46,35,111,119,110,101,114,41,116,104,114,111,119,32,110,101,119,32,69,114,114,111,114,40,92,34,110,111,116,32,97,110,32,111,119,110,101,114,92,34,41,59,116,104,105,115,46,35,99,117,114,114,101,110,99,121,61,99,117,114,114,101,110,99,121,125,104,97,115,40,118,97,108,105,100,97,116,111,114,41,123,114,101,116,117,114,110,32,66,111,111,108,101,97,110,40,118,111,105,100,32,48,33,61,61,116,104,105,115,46,35,118,97,108,105,100,97,116,111,114,115,91,118,97,108,105,100,97,116,111,114,93,41,125,97,115,121,110,99,32,97,100,100,86,97,108,105,100,97,116,111,114,40,118,97,108,105,100,97,116,111,114,41,123,105,102,40,116,104,105,115,46,104,97,115,40,118,97,108,105,100,97,116,111,114,41,41,116,104,114,111,119,32,110,101,119,32,69,114,114,111,114,40,92,34,97,108,114,101,97,100,121,32,97,32,118,97,108,105,100,97,116,111,114,92,34,41,59,99,111,110,115,116,32,98,97,108,97,110,99,101,61,97,119,97,105,116,32,109,115,103,46,115,116,97,116,105,99,67,97,108,108,40,116,104,105,115,46,99,117,114,114,101,110,99,121,44,92,34,98,97,108,97,110,99,101,79,102,92,34,44,91,109,115,103,46,115,101,110,100,101,114,93,41,59,105,102,40,98,97,108,97,110,99,101,60,116,104,105,115,46,109,105,110,105,109,117,109,66,97,108,97,110,99,101,41,116,104,114,111,119,32,110,101,119,32,69,114,114,111,114,40,96,98,97,108,97,110,99,101,32,116,111,32,108,111,119,33,32,103,111,116,58,32,36,123,98,97,108,97,110,99,101,125,32,110,101,101,100,58,32,36,123,116,104,105,115,46,35,109,105,110,105,109,117,109,66,97,108,97,110,99,101,125,96,41,59,116,104,105,115,46,35,116,111,116,97,108,86,97,108,105,100,97,116,111,114,115,43,61,49,44,116,104,105,115,46,35,118,97,108,105,100,97,116,111,114,115,91,118,97,108,105,100,97,116,111,114,93,61,123,102,105,114,115,116,83,101,101,110,58,40,110,101,119,32,68,97,116,101,41,46,103,101,116,84,105,109,101,40,41,44,97,99,116,105,118,101,58,33,48,125,125,114,101,109,111,118,101,86,97,108,105,100,97,116,111,114,40,118,97,108,105,100,97,116,111,114,41,123,105,102,40,33,116,104,105,115,46,104,97,115,40,118,97,108,105,100,97,116,111,114,41,41,116,104,114,111,119,32,110,101,119,32,69,114,114,111,114,40,92,34,118,97,108,105,100,97,116,111,114,32,110,111,116,32,102,111,117,110,100,92,34,41,59,116,104,105,115,46,35,116,111,116,97,108,86,97,108,105,100,97,116,111,114,115,45,61,49,44,100,101,108,101,116,101,32,116,104,105,115,46,35,118,97,108,105,100,97,116,111,114,115,91,118,97,108,105,100,97,116,111,114,93,125,97,115,121,110,99,32,117,112,100,97,116,101,86,97,108,105,100,97,116,111,114,40,118,97,108,105,100,97,116,111,114,44,97,99,116,105,118,101,41,123,105,102,40,33,116,104,105,115,46,104,97,115,40,118,97,108,105,100,97,116,111,114,41,41,116,104,114,111,119,32,110,101,119,32,69,114,114,111,114,40,92,34,118,97,108,105,100,97,116,111,114,32,110,111,116,32,102,111,117,110,100,92,34,41,59,99,111,110,115,116,32,98,97,108,97,110,99,101,61,97,119,97,105,116,32,109,115,103,46,115,116,97,116,105,99,67,97,108,108,40,116,104,105,115,46,99,117,114,114,101,110,99,121,44,92,34,98,97,108,97,110,99,101,79,102,92,34,44,91,109,115,103,46,115,101,110,100,101,114,93,41,59,105,102,40,98,97,108,97,110,99,101,60,116,104,105,115,46,109,105,110,105,109,117,109,66,97,108,97,110,99,101,38,38,116,104,105,115,46,35,118,97,108,105,100,97,116,111,114,115,91,118,97,108,105,100,97,116,111,114,93,46,97,99,116,105,118,101,38,38,40,116,104,105,115,46,35,118,97,108,105,100,97,116,111,114,115,91,118,97,108,105,100,97,116,111,114,93,46,97,99,116,105,118,101,61,33,49,41,44,98,97,108,97,110,99,101,60,116,104,105,115,46,109,105,110,105,109,117,109,66,97,108,97,110,99,101,41,116,104,114,111,119,32,110,101,119,32,69,114,114,111,114,40,96,98,97,108,97,110,99,101,32,116,111,32,108,111,119,33,32,103,111,116,58,32,36,123,98,97,108,97,110,99,101,125,32,110,101,101,100,58,32,36,123,116,104,105,115,46,35,109,105,110,105,109,117,109,66,97,108,97,110,99,101,125,96,41,59,116,104,105,115,46,35,118,97,108,105,100,97,116,111,114,115,91,118,97,108,105,100,97,116,111,114,93,46,97,99,116,105,118,101,61,97,99,116,105,118,101,125,125,59,34,44,34,99,111,110,115,116,114,117,99,116,111,114,80,97,114,97,109,101,116,101,114,115,34,58,91,34,105,104,110,121,50,103,113,103,104,111,55,112,102,50,99,103,98,107,109,113,106,121,103,120,108,120,101,114,114,120,122,109,122,51,102,101,51,120,119,53,51,110,110,107,110,117,51,119,107,102,100,115,52,98,100,122,118,50,114,34,93,125";const v=new o.default,x=w,M=N,E=y,k=B;globalThis.BigNumber=BigNumber,globalThis.peernet=globalThis.peernet||{},globalThis.contracts={};const q=(e,t,r)=>{let s;return s=r?.length>0?contracts[e][t](...r):contracts[e][t],s},T=async e=>{const t=e.decoded.constructorParameters;try{const r=new Function(e.decoded.contract)();globalThis.msg=_(e.decoded.creator),contracts[await e.hash]=await new r(...t),v.postMessage({type:"debug",messages:[`loaded contract: ${await e.hash}`,`size: ${f(e.encoded.length)}`]})}catch(t){console.log(t),v.postMessage({type:"contractError",hash:await e.hash})}},S=async(e,t,r)=>{try{let s;return s=contracts[e].fallback?await contracts[e].fallback(t,r):await contracts[e][t](...r),s}catch(e){throw e}},_=(e=globalThis.peerid)=>({sender:e,call:S,staticCall:q}),P=async e=>{const t=e.id;if("init"===e.type)try{await(async({contracts:e,blocks:t,peerid:r})=>{globalThis.peernet.codecs={"contract-message":{codec:parseInt("63636d",16),hashAlg:"keccak-256"},"transaction-message":{codec:parseInt("746d",16),hashAlg:"keccak-256"},"block-message":{codec:parseInt("626d",16),hashAlg:"keccak-256"}},globalThis.peerid=r,e=[x,M,E,k],e=await Promise.all(e.map((async e=>(e=await new ContractMessage(new Uint8Array(e.split(","))),await T(e),e))));let s={hash:"0x0"};if(t?.length>0){const e=await new o.default("./block-worker.js",{serialization:"advanced",type:"module"});(t=await e.once([t[t.length-1]])).length>0&&(s=t[t.length-1].decoded,s=await new BlockMessage(s),s={...s.decoded,hash:await s.hash}),globalThis.blocks=t}v.postMessage({type:"machine-ready",lastBlock:s})})(e.input)}catch(e){v.postMessage({type:"initError",message:e.message,id:t})}if("get"===e.type)try{const r=await q(e.input.contract,e.input.method,e.input.params);v.postMessage({type:"response",id:t,value:r})}catch(e){v.postMessage({type:"fetchError",message:e.message,id:t})}if("execute"===e.type)try{const r=await S(e.input.contract,e.input.method,e.input.params);v.postMessage({type:"response",id:t,value:r})}catch(e){v.postMessage({type:"executionError",message:e.message,id:t})}};v.onmessage((e=>P(e))),exports.unique=e=>e.filter(((e,t,r)=>r.indexOf(e)==t));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leofcoin/chain",
3
- "version": "1.3.1",
3
+ "version": "1.3.3",
4
4
  "description": "Official javascript implementation",
5
5
  "main": "./dist/node.js",
6
6
  "module": "./dist/chain.esm",
package/src/chain.js CHANGED
@@ -157,7 +157,7 @@ export default class Chain {
157
157
  const initialized = await contractStore.has(addresses.contractFactory)
158
158
  if (!initialized) await this.#setup()
159
159
 
160
- this.#machine = await new Machine()
160
+
161
161
  this.utils = { BigNumber, formatUnits, parseUnits }
162
162
 
163
163
  try {
@@ -201,6 +201,11 @@ export default class Chain {
201
201
 
202
202
  // load local blocks
203
203
  await this.resolveBlocks()
204
+ this.#machine = await new Machine(this.#blocks)
205
+ // for (const block of this.#blocks) {
206
+ // block.loaded = true
207
+ // }
208
+ await this.#loadBlocks(this.#blocks)
204
209
  return this
205
210
  }
206
211
 
@@ -228,7 +233,7 @@ export default class Chain {
228
233
 
229
234
  const end = this.#blocks.length
230
235
  const start = (this.#blocks.length) - blocksSynced
231
- await this.#loadBlocks(this.#blocks)
236
+ await this.#loadBlocks(this.blocks.slice(start))
232
237
  this.#lastBlock = this.#blocks[this.#blocks.length - 1]
233
238
  const message = await new BlockMessage(this.lastBlock)
234
239
  await blockStore.put(await message.hash, message.encoded)
@@ -260,9 +265,9 @@ async resolveBlock(hash) {
260
265
  if (!await peernet.has(hash, 'block')) await peernet.put(hash, block.encoded, 'block')
261
266
  const size = block.encoded.length || block.encoded.byteLength
262
267
  block = {...block.decoded, hash}
263
- if (this.#blocks[block.index]) throw `invalid block ${hash} @${block.index}`
268
+ if (this.#blocks[block.index] && this.#blocks[block.index].hash !== block.hash) throw `invalid block ${hash} @${block.index}`
264
269
  this.#blocks[block.index] = block
265
- console.log(`loaded block: ${hash} @${block.index} ${formatBytes(size)}`);
270
+ console.log(`resolved block: ${hash} @${block.index} ${formatBytes(size)}`);
266
271
  if (block.previousHash !== '0x0') {
267
272
  return this.resolveBlock(block.previousHash)
268
273
  }
@@ -276,7 +281,7 @@ async resolveBlock(hash) {
276
281
  if (hash && hash !== '0x0')
277
282
  await this.resolveBlock(hash)
278
283
  this.#lastBlock = this.#blocks[this.#blocks.length - 1]
279
- await this.#loadBlocks(this.#blocks)
284
+
280
285
  } catch (e) {
281
286
  await chainStore.put('lastBlock', new TextEncoder().encode('0x0'))
282
287
  return this.resolveBlocks()
@@ -295,7 +300,8 @@ async resolveBlock(hash) {
295
300
  console.log(e);
296
301
  }
297
302
  }
298
- block.loaded = true
303
+ this.#blocks[block.index].loaded = true
304
+ console.log(`loaded block: ${block.hash} @${block.index}`);
299
305
  // let message = await peernet.get(block.hash, 'block')
300
306
 
301
307
  // const compressed = pako.deflate(message);
@@ -347,8 +353,6 @@ async resolveBlock(hash) {
347
353
  // transaction = new TransactionMessage(transaction)
348
354
  // return transaction
349
355
  // }
350
-
351
- console.log(blockMessage);
352
356
  const deletions = await Promise.all(blockMessage.decoded.transactions
353
357
  .map(async transaction => transactionPoolStore.delete(await transaction.hash)))
354
358
  const hash = await blockMessage.hash
package/src/machine.js CHANGED
@@ -11,8 +11,8 @@ export default class Machine {
11
11
  #nonces = {}
12
12
  lastBlock = {index: 0, hash: '0x0', previousHash: '0x0'}
13
13
 
14
- constructor() {
15
- return this.#init()
14
+ constructor(blocks) {
15
+ return this.#init(blocks)
16
16
  }
17
17
 
18
18
  #createMessage(sender = peernet.selectedAccount) {
@@ -49,7 +49,7 @@ export default class Machine {
49
49
 
50
50
  }
51
51
 
52
- async #init() {
52
+ async #init(blocks) {
53
53
  return new Promise(async (resolve) => {
54
54
  pubsub.subscribe('machine.ready', () => {
55
55
  resolve(this)
@@ -58,7 +58,7 @@ export default class Machine {
58
58
  this.worker = await new EasyWorker(join(__dirname, './workers/machine-worker.js'), {serialization: 'advanced', type:'module'})
59
59
  this.worker.onmessage(this.#onmessage.bind(this))
60
60
 
61
- const blocks = await blockStore.values()
61
+ // const blocks = await blockStore.values()
62
62
  const contracts = await Promise.all([
63
63
  contractStore.get(contractFactory),
64
64
  contractStore.get(nativeToken),