@leofcoin/chain 1.1.6 → 1.1.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chain.js +38 -25
- package/dist/module/chain.js +38 -25
- package/dist/module/workers/machine-worker.js +56 -3
- package/dist/workers/block-worker.js +1 -1
- package/dist/workers/machine-worker.js +1 -1
- package/package.json +1 -1
- package/src/chain.js +41 -31
- package/src/machine.js +3 -0
- package/src/workers/block-worker.js +17 -18
- package/src/workers/machine-worker.js +12 -1
package/dist/chain.js
CHANGED
|
@@ -197,6 +197,8 @@ const formatBytes = (bytes, decimals = 2) => {
|
|
|
197
197
|
class Machine {
|
|
198
198
|
#contracts = {}
|
|
199
199
|
#nonces = {}
|
|
200
|
+
lastBlock = {}
|
|
201
|
+
|
|
200
202
|
constructor() {
|
|
201
203
|
return this.#init()
|
|
202
204
|
}
|
|
@@ -225,6 +227,7 @@ class Machine {
|
|
|
225
227
|
data.messages.forEach(message => debug(message));
|
|
226
228
|
break
|
|
227
229
|
case 'machine-ready':
|
|
230
|
+
this.lastBlock = data.lastBlock;
|
|
228
231
|
pubsub.publish('machine.ready');
|
|
229
232
|
break
|
|
230
233
|
case 'response':
|
|
@@ -408,7 +411,7 @@ class Chain {
|
|
|
408
411
|
#blocks = []
|
|
409
412
|
#machine
|
|
410
413
|
#runningEpoch = false
|
|
411
|
-
#lastBlock = {index: 0, previousHash: '0x0'}
|
|
414
|
+
#lastBlock = {index: 0, hash: '0x0', previousHash: '0x0'}
|
|
412
415
|
|
|
413
416
|
#jail = []
|
|
414
417
|
|
|
@@ -495,18 +498,20 @@ class Chain {
|
|
|
495
498
|
for (const peer of peernet.connections) {
|
|
496
499
|
if (peer.peerId !== this.id) {
|
|
497
500
|
let data = await new peernet.protos['peernet-request']({request: 'lastBlock'});
|
|
498
|
-
|
|
499
501
|
const node = await peernet.prepareMessage(data);
|
|
500
502
|
promises.push(peer.request(node.encoded));
|
|
501
503
|
}
|
|
502
504
|
}
|
|
503
|
-
// if (this.)
|
|
504
|
-
|
|
505
505
|
promises = await Promise.allSettled(promises);
|
|
506
|
-
promises = promises.
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
506
|
+
promises = promises.filter(({status}) => status === 'fulfilled');
|
|
507
|
+
promises = promises.map(({value}) => new peernet.protos['peernet-response'](value));
|
|
508
|
+
promises = await Promise.all(promises);
|
|
509
|
+
promises = promises.map(node => node.decoded.response);
|
|
510
|
+
promises = promises.reduce((set, value) => {
|
|
511
|
+
|
|
512
|
+
if (value.index > set.index) {
|
|
513
|
+
set.index = value.index;
|
|
514
|
+
set.hash = value.hash;
|
|
510
515
|
}
|
|
511
516
|
return set
|
|
512
517
|
}, {index: 0, hash: '0x0'});
|
|
@@ -545,31 +550,39 @@ class Chain {
|
|
|
545
550
|
peernet.subscribe('validator:timeout', this.#validatorTimeout.bind(this));
|
|
546
551
|
|
|
547
552
|
pubsub.subscribe('peer:connected', this.#peerConnected.bind(this));
|
|
553
|
+
console.log(this.#machine.lastBlock);
|
|
554
|
+
// let a = await new BlockMessage(this.#machine.lastBlock)
|
|
555
|
+
// console.log(a.decoded);
|
|
556
|
+
// console.log(await a.hash);
|
|
548
557
|
|
|
549
558
|
try {
|
|
550
|
-
let localBlock
|
|
559
|
+
let localBlock;
|
|
560
|
+
try {
|
|
561
|
+
localBlock = await chainStore.get('lastBlock');
|
|
562
|
+
console.log({localBlock});
|
|
563
|
+
} catch(e) {
|
|
564
|
+
await chainStore.put('lastBlock', '0x0');
|
|
565
|
+
localBlock = await chainStore.get('lastBlock');
|
|
566
|
+
}
|
|
551
567
|
localBlock = new TextDecoder().decode(localBlock);
|
|
568
|
+
|
|
569
|
+
console.log({localBlock});
|
|
552
570
|
if (localBlock && localBlock !== '0x0') {
|
|
553
571
|
localBlock = await peernet.get(localBlock);
|
|
554
572
|
localBlock = await new BlockMessage(localBlock);
|
|
555
573
|
this.#lastBlock = {...localBlock.decoded, hash: await localBlock.hash};
|
|
574
|
+
} else if (this.#machine.lastBlock?.hash) {
|
|
575
|
+
// todo remove when network is running
|
|
576
|
+
// recovering chain (not needed if multiple peers are online)
|
|
577
|
+
this.#lastBlock = this.#machine.lastBlock;
|
|
578
|
+
console.log(this.#lastBlock);
|
|
579
|
+
await chainStore.put('lastBlock', this.#lastBlock.hash);
|
|
556
580
|
} else {
|
|
557
581
|
await this.#sync();
|
|
558
|
-
}
|
|
559
|
-
|
|
560
|
-
// console.log(this.lastBlock.decoded.transactions);
|
|
582
|
+
}
|
|
561
583
|
} catch (e) {
|
|
562
584
|
console.log({e});
|
|
563
|
-
|
|
564
|
-
let localBlock = await chainStore.get('lastBlock');
|
|
565
|
-
localBlock = new TextDecoder().decode(localBlock);
|
|
566
|
-
if (localBlock && localBlock !== '0x0') {
|
|
567
|
-
localBlock = await peernet.get(localBlock);
|
|
568
|
-
localBlock = await new BlockMessage(localBlock);
|
|
569
|
-
this.#lastBlock = {...localBlock.decoded, hash: await localBlock.hash};
|
|
570
|
-
} else {
|
|
571
|
-
await this.#sync();
|
|
572
|
-
}
|
|
585
|
+
|
|
573
586
|
|
|
574
587
|
|
|
575
588
|
// this.#setup()
|
|
@@ -594,7 +607,7 @@ class Chain {
|
|
|
594
607
|
console.log({response});
|
|
595
608
|
response = await new globalThis.peernet.protos['peernet-response'](response);
|
|
596
609
|
let lastBlock = response.decoded.response;
|
|
597
|
-
|
|
610
|
+
console.log({lastBlock});
|
|
598
611
|
if (!this.lastBlock || this.lastBlock.index < lastBlock.index) {
|
|
599
612
|
// TODO: check if valid
|
|
600
613
|
const localIndex = this.lastBlock ? this.lastBlock.index : 0;
|
|
@@ -629,7 +642,7 @@ class Chain {
|
|
|
629
642
|
}
|
|
630
643
|
|
|
631
644
|
async #lastBlockHandler() {
|
|
632
|
-
return new peernet.protos['peernet-response']({response: { hash: this
|
|
645
|
+
return new peernet.protos['peernet-response']({response: { hash: this.#lastBlock?.hash, index: this.#lastBlock?.index }})
|
|
633
646
|
}
|
|
634
647
|
|
|
635
648
|
async resolveBlock(hash) {
|
|
@@ -641,7 +654,7 @@ async resolveBlock(hash) {
|
|
|
641
654
|
block = {...block.decoded, hash};
|
|
642
655
|
this.#blocks[block.index] = block;
|
|
643
656
|
console.log(`loaded block: ${hash} @${block.index} ${formatBytes(size)}`);
|
|
644
|
-
if (block.
|
|
657
|
+
if (block.previousHash !== '0x0') {
|
|
645
658
|
return this.resolveBlock(block.previousHash)
|
|
646
659
|
}
|
|
647
660
|
}
|
package/dist/module/chain.js
CHANGED
|
@@ -189,6 +189,8 @@ const formatBytes = (bytes, decimals = 2) => {
|
|
|
189
189
|
class Machine {
|
|
190
190
|
#contracts = {}
|
|
191
191
|
#nonces = {}
|
|
192
|
+
lastBlock = {}
|
|
193
|
+
|
|
192
194
|
constructor() {
|
|
193
195
|
return this.#init()
|
|
194
196
|
}
|
|
@@ -217,6 +219,7 @@ class Machine {
|
|
|
217
219
|
data.messages.forEach(message => debug(message));
|
|
218
220
|
break
|
|
219
221
|
case 'machine-ready':
|
|
222
|
+
this.lastBlock = data.lastBlock;
|
|
220
223
|
pubsub.publish('machine.ready');
|
|
221
224
|
break
|
|
222
225
|
case 'response':
|
|
@@ -400,7 +403,7 @@ class Chain {
|
|
|
400
403
|
#blocks = []
|
|
401
404
|
#machine
|
|
402
405
|
#runningEpoch = false
|
|
403
|
-
#lastBlock = {index: 0, previousHash: '0x0'}
|
|
406
|
+
#lastBlock = {index: 0, hash: '0x0', previousHash: '0x0'}
|
|
404
407
|
|
|
405
408
|
#jail = []
|
|
406
409
|
|
|
@@ -487,18 +490,20 @@ class Chain {
|
|
|
487
490
|
for (const peer of peernet.connections) {
|
|
488
491
|
if (peer.peerId !== this.id) {
|
|
489
492
|
let data = await new peernet.protos['peernet-request']({request: 'lastBlock'});
|
|
490
|
-
|
|
491
493
|
const node = await peernet.prepareMessage(data);
|
|
492
494
|
promises.push(peer.request(node.encoded));
|
|
493
495
|
}
|
|
494
496
|
}
|
|
495
|
-
// if (this.)
|
|
496
|
-
|
|
497
497
|
promises = await Promise.allSettled(promises);
|
|
498
|
-
promises = promises.
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
498
|
+
promises = promises.filter(({status}) => status === 'fulfilled');
|
|
499
|
+
promises = promises.map(({value}) => new peernet.protos['peernet-response'](value));
|
|
500
|
+
promises = await Promise.all(promises);
|
|
501
|
+
promises = promises.map(node => node.decoded.response);
|
|
502
|
+
promises = promises.reduce((set, value) => {
|
|
503
|
+
|
|
504
|
+
if (value.index > set.index) {
|
|
505
|
+
set.index = value.index;
|
|
506
|
+
set.hash = value.hash;
|
|
502
507
|
}
|
|
503
508
|
return set
|
|
504
509
|
}, {index: 0, hash: '0x0'});
|
|
@@ -537,31 +542,39 @@ class Chain {
|
|
|
537
542
|
peernet.subscribe('validator:timeout', this.#validatorTimeout.bind(this));
|
|
538
543
|
|
|
539
544
|
pubsub.subscribe('peer:connected', this.#peerConnected.bind(this));
|
|
545
|
+
console.log(this.#machine.lastBlock);
|
|
546
|
+
// let a = await new BlockMessage(this.#machine.lastBlock)
|
|
547
|
+
// console.log(a.decoded);
|
|
548
|
+
// console.log(await a.hash);
|
|
540
549
|
|
|
541
550
|
try {
|
|
542
|
-
let localBlock
|
|
551
|
+
let localBlock;
|
|
552
|
+
try {
|
|
553
|
+
localBlock = await chainStore.get('lastBlock');
|
|
554
|
+
console.log({localBlock});
|
|
555
|
+
} catch(e) {
|
|
556
|
+
await chainStore.put('lastBlock', '0x0');
|
|
557
|
+
localBlock = await chainStore.get('lastBlock');
|
|
558
|
+
}
|
|
543
559
|
localBlock = new TextDecoder().decode(localBlock);
|
|
560
|
+
|
|
561
|
+
console.log({localBlock});
|
|
544
562
|
if (localBlock && localBlock !== '0x0') {
|
|
545
563
|
localBlock = await peernet.get(localBlock);
|
|
546
564
|
localBlock = await new BlockMessage(localBlock);
|
|
547
565
|
this.#lastBlock = {...localBlock.decoded, hash: await localBlock.hash};
|
|
566
|
+
} else if (this.#machine.lastBlock?.hash) {
|
|
567
|
+
// todo remove when network is running
|
|
568
|
+
// recovering chain (not needed if multiple peers are online)
|
|
569
|
+
this.#lastBlock = this.#machine.lastBlock;
|
|
570
|
+
console.log(this.#lastBlock);
|
|
571
|
+
await chainStore.put('lastBlock', this.#lastBlock.hash);
|
|
548
572
|
} else {
|
|
549
573
|
await this.#sync();
|
|
550
|
-
}
|
|
551
|
-
|
|
552
|
-
// console.log(this.lastBlock.decoded.transactions);
|
|
574
|
+
}
|
|
553
575
|
} catch (e) {
|
|
554
576
|
console.log({e});
|
|
555
|
-
|
|
556
|
-
let localBlock = await chainStore.get('lastBlock');
|
|
557
|
-
localBlock = new TextDecoder().decode(localBlock);
|
|
558
|
-
if (localBlock && localBlock !== '0x0') {
|
|
559
|
-
localBlock = await peernet.get(localBlock);
|
|
560
|
-
localBlock = await new BlockMessage(localBlock);
|
|
561
|
-
this.#lastBlock = {...localBlock.decoded, hash: await localBlock.hash};
|
|
562
|
-
} else {
|
|
563
|
-
await this.#sync();
|
|
564
|
-
}
|
|
577
|
+
|
|
565
578
|
|
|
566
579
|
|
|
567
580
|
// this.#setup()
|
|
@@ -586,7 +599,7 @@ class Chain {
|
|
|
586
599
|
console.log({response});
|
|
587
600
|
response = await new globalThis.peernet.protos['peernet-response'](response);
|
|
588
601
|
let lastBlock = response.decoded.response;
|
|
589
|
-
|
|
602
|
+
console.log({lastBlock});
|
|
590
603
|
if (!this.lastBlock || this.lastBlock.index < lastBlock.index) {
|
|
591
604
|
// TODO: check if valid
|
|
592
605
|
const localIndex = this.lastBlock ? this.lastBlock.index : 0;
|
|
@@ -621,7 +634,7 @@ class Chain {
|
|
|
621
634
|
}
|
|
622
635
|
|
|
623
636
|
async #lastBlockHandler() {
|
|
624
|
-
return new peernet.protos['peernet-response']({response: { hash: this
|
|
637
|
+
return new peernet.protos['peernet-response']({response: { hash: this.#lastBlock?.hash, index: this.#lastBlock?.index }})
|
|
625
638
|
}
|
|
626
639
|
|
|
627
640
|
async resolveBlock(hash) {
|
|
@@ -633,7 +646,7 @@ async resolveBlock(hash) {
|
|
|
633
646
|
block = {...block.decoded, hash};
|
|
634
647
|
this.#blocks[block.index] = block;
|
|
635
648
|
console.log(`loaded block: ${hash} @${block.index} ${formatBytes(size)}`);
|
|
636
|
-
if (block.
|
|
649
|
+
if (block.previousHash !== '0x0') {
|
|
637
650
|
return this.resolveBlock(block.previousHash)
|
|
638
651
|
}
|
|
639
652
|
}
|
|
@@ -6,7 +6,7 @@ import '@ethersproject/bignumber';
|
|
|
6
6
|
import { fork } from 'child_process';
|
|
7
7
|
import { join } from 'path';
|
|
8
8
|
|
|
9
|
-
var proto = `
|
|
9
|
+
var proto$1 = `
|
|
10
10
|
message ContractMessage {
|
|
11
11
|
required string creator = 1;
|
|
12
12
|
required bytes contract = 2;
|
|
@@ -24,7 +24,49 @@ class ContractMessage extends FormatInterface {
|
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
constructor(buffer) {
|
|
27
|
-
super(buffer, proto, {name: 'contract-message'});
|
|
27
|
+
super(buffer, proto$1, {name: 'contract-message'});
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
var proto = `
|
|
32
|
+
message ValidatorMessage {
|
|
33
|
+
required string address = 1;
|
|
34
|
+
required string reward = 2;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
message Transaction {
|
|
38
|
+
required string hash = 1;
|
|
39
|
+
required uint64 timestamp = 2;
|
|
40
|
+
required string from = 3;
|
|
41
|
+
required string to = 4;
|
|
42
|
+
required uint64 nonce = 5;
|
|
43
|
+
required string method = 6;
|
|
44
|
+
repeated string params = 7;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
message BlockMessage {
|
|
48
|
+
required uint64 index = 1;
|
|
49
|
+
required string previousHash = 3;
|
|
50
|
+
required uint64 timestamp = 4;
|
|
51
|
+
required uint64 reward = 5;
|
|
52
|
+
required string fees = 6;
|
|
53
|
+
repeated Transaction transactions = 7;
|
|
54
|
+
repeated ValidatorMessage validators = 8;
|
|
55
|
+
}
|
|
56
|
+
`;
|
|
57
|
+
|
|
58
|
+
class BlockMessage extends FormatInterface {
|
|
59
|
+
get keys() {
|
|
60
|
+
return ['index', 'previousHash', 'timestamp', 'reward', 'fees', 'transactions', 'validators']
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
get messageName() {
|
|
64
|
+
return 'BlockMessage'
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
constructor(buffer) {
|
|
68
|
+
const name = 'block-message';
|
|
69
|
+
super(buffer, proto, {name});
|
|
28
70
|
}
|
|
29
71
|
}
|
|
30
72
|
|
|
@@ -441,6 +483,7 @@ const _init = async ({ contracts, blocks, peerid })=> {
|
|
|
441
483
|
const worker = fork(join(__dirname, './block-worker.js'), {serialization: 'advanced'});
|
|
442
484
|
// worker.on('message')
|
|
443
485
|
worker.once('message', async (blocks) => {
|
|
486
|
+
console.log({blocks});
|
|
444
487
|
for (const block of blocks) {
|
|
445
488
|
await Promise.all(block.decoded.transactions.map(async message => {
|
|
446
489
|
const {from, to, method, params} = message.decoded;
|
|
@@ -449,7 +492,17 @@ const _init = async ({ contracts, blocks, peerid })=> {
|
|
|
449
492
|
await execute(to, method, params);
|
|
450
493
|
}));
|
|
451
494
|
}
|
|
452
|
-
|
|
495
|
+
let lastBlock;
|
|
496
|
+
if (blocks.length > 0) {
|
|
497
|
+
lastBlock = blocks[blocks.length - 1].decoded;
|
|
498
|
+
lastBlock.transactions = lastBlock.transactions.map(transaction => ({...transaction.decoded}));
|
|
499
|
+
lastBlock = await new BlockMessage(lastBlock);
|
|
500
|
+
lastBlock = {
|
|
501
|
+
...lastBlock.decoded,
|
|
502
|
+
hash: await lastBlock.hash
|
|
503
|
+
};
|
|
504
|
+
}
|
|
505
|
+
process.send({type: 'machine-ready', lastBlock });
|
|
453
506
|
worker.kill();
|
|
454
507
|
|
|
455
508
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var e=require("@leofcoin/codec-format-interface"),r=require("bn.js"),t=require("@ethersproject/bytes"),s=require("@ethersproject/logger");require("@ethersproject/bignumber");var n=require("child_process"),i=require("path");function o(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var a=o(r);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
|
|
1
|
+
"use strict";var e=require("@leofcoin/codec-format-interface"),r=require("bn.js"),t=require("@ethersproject/bytes"),s=require("@ethersproject/logger");require("@ethersproject/bignumber");var n=require("child_process"),i=require("path");function o(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var a=o(r);class TransactionMessage extends e.FormatInterface{get keys(){return["timestamp","from","to","nonce","method","params","signature"]}get messageName(){return"TransactionMessage"}constructor(e){super(e,"\n\nmessage TransactionMessage {\n required uint64 timestamp = 1;\n required string from = 2;\n required string to = 3;\n required uint64 nonce = 4;\n required string method = 5;\n repeated string params = 6;\n required string signature = 7;\n}\n",{name:"transaction-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 m=!1;class BigNumber{constructor(e,r){e!==c&&g.throwError("cannot call constructor directly; use BigNumber.from",s.Logger.errors.UNSUPPORTED_OPERATION,{operation:"new (BigNumber)"}),this._hex=r,this._isBigNumber=!0,Object.freeze(this)}fromTwos(e){return h(l(this).fromTwos(e))}toTwos(e){return h(l(this).toTwos(e))}abs(){return"-"===this._hex[0]?BigNumber.from(this._hex.substring(1)):this}add(e){return h(l(this).add(l(e)))}sub(e){return h(l(this).sub(l(e)))}div(e){return BigNumber.from(e).isZero()&&b("division-by-zero","div"),h(l(this).div(l(e)))}mul(e){return h(l(this).mul(l(e)))}mod(e){const r=l(e);return r.isNeg()&&b("division-by-zero","mod"),h(l(this).umod(r))}pow(e){const r=l(e);return r.isNeg()&&b("negative-power","pow"),h(l(this).pow(r))}and(e){const r=l(e);return(this.isNegative()||r.isNeg())&&b("unbound-bitwise-result","and"),h(l(this).and(r))}or(e){const r=l(e);return(this.isNegative()||r.isNeg())&&b("unbound-bitwise-result","or"),h(l(this).or(r))}xor(e){const r=l(e);return(this.isNegative()||r.isNeg())&&b("unbound-bitwise-result","xor"),h(l(this).xor(r))}mask(e){return(this.isNegative()||e<0)&&b("negative-width","mask"),h(l(this).maskn(e))}shl(e){return(this.isNegative()||e<0)&&b("negative-width","shl"),h(l(this).shln(e))}shr(e){return(this.isNegative()||e<0)&&b("negative-width","shr"),h(l(this).shrn(e))}eq(e){return l(this).eq(l(e))}lt(e){return l(this).lt(l(e))}lte(e){return l(this).lte(l(e))}gt(e){return l(this).gt(l(e))}gte(e){return l(this).gte(l(e))}isNegative(){return"-"===this._hex[0]}isZero(){return l(this).isZero()}toNumber(){try{return l(this).toNumber()}catch(e){b("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]?m||(m=!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,{})),l(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,d(e)):e.match(/^-?[0-9]+$/)?new BigNumber(c,d(new u(e))):g.throwArgumentError("invalid BigNumber string","value",e);if("number"==typeof e)return e%1&&b("underflow","BigNumber.from",e),(e>=9007199254740991||e<=-9007199254740991)&&b("overflow","BigNumber.from",e),BigNumber.from(String(e));const r=e;if("bigint"==typeof r)return BigNumber.from(r.toString());if(t.isBytes(r))return BigNumber.from(t.hexlify(r));if(r)if(r.toHexString){const e=r.toHexString();if("string"==typeof e)return BigNumber.from(e)}else{let e=r._hex;if(null==e&&"BigNumber"===r.type&&(e=r.hex),"string"==typeof e&&(t.isHexString(e)||"-"===e[0]&&t.isHexString(e.substring(1))))return BigNumber.from(e)}return g.throwArgumentError("invalid BigNumber value","value",e)}static isBigNumber(e){return!(!e||!e._isBigNumber)}}function d(e){if("string"!=typeof e)return d(e.toString(16));if("-"===e[0])return"-"===(e=e.substring(1))[0]&&g.throwArgumentError("invalid hex","value",e),"0x00"===(e=d(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 h(e){return BigNumber.from(d(e))}function l(e){const r=BigNumber.from(e).toHexString();return"-"===r[0]?new u("-"+r.substring(3),16):new u(r.substring(2),16)}function b(e,r,t){const n={fault:e,operation:r};return null!=t&&(n.value=t),g.throwError(e,s.Logger.errors.NUMERIC_FAULT,n)}new s.Logger("units/5.6.1");const f=["Bytes","KB","MB","GB","TB","PB","EB","ZB","YB"];globalThis.BigNumber=BigNumber,globalThis.peernet=globalThis.peernet||{},globalThis.contracts={};const p=async e=>(e=(e=await Promise.all(e.map((e=>new BlockMessage(e))))).sort(((e,r)=>e.decoded.timestamp-r.decoded.timestamp)),e=await Promise.all(e.map((e=>new Promise((async(r,t)=>{n.fork(i.join(__dirname,"./transaction-worker.js"),{serialization:"advanced"}),e.decoded.transactions=await Promise.all(e.decoded.transactions.map((async e=>new TransactionMessage(e))));const s=e.encoded.length||e.encoded.byteLength;console.log(`loaded block: ${await e.hash} @${e.decoded.index} ${((e,r=2)=>{if(0===e)return"0 Bytes";r<0&&(r=0);const t=Math.floor(Math.log(e)/Math.log(1024));return`${parseFloat((e/Math.pow(1024,t)).toFixed(r))} ${f[t]}`})(s)}`),r(e)}))))),e),N=async e=>{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"}},e=await p(e),globalThis.process?process.send(e):postMessage(e)};globalThis.process?process.on("message",N):onmessage=e=>N(e.data);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var t=require("@leofcoin/codec-format-interface"),e=require("bn.js"),r=require("@ethersproject/bytes"),s=require("@ethersproject/logger");require("@ethersproject/bignumber");var n=require("child_process"),i=require("path");function o(t){return t&&"object"==typeof t&&"default"in t?t:{default:t}}var a=o(e);class ContractMessage extends t.FormatInterface{get keys(){return["creator","contract","constructorParameters"]}get messageName(){return"ContractMessage"}constructor(t){super(t,"\nmessage ContractMessage {\n required string creator = 1;\n required bytes contract = 2;\n repeated string constructorParameters = 3;\n}\n",{name:"contract-message"})}}var c=a.default.BN;const u=new s.Logger("bignumber/5.6.2"),g={};let h=!1;class BigNumber{constructor(t,e){t!==g&&u.throwError("cannot call constructor directly; use BigNumber.from",s.Logger.errors.UNSUPPORTED_OPERATION,{operation:"new (BigNumber)"}),this._hex=e,this._isBigNumber=!0,Object.freeze(this)}fromTwos(t){return m(d(this).fromTwos(t))}toTwos(t){return m(d(this).toTwos(t))}abs(){return"-"===this._hex[0]?BigNumber.from(this._hex.substring(1)):this}add(t){return m(d(this).add(d(t)))}sub(t){return m(d(this).sub(d(t)))}div(t){return BigNumber.from(t).isZero()&&b("division-by-zero","div"),m(d(this).div(d(t)))}mul(t){return m(d(this).mul(d(t)))}mod(t){const e=d(t);return e.isNeg()&&b("division-by-zero","mod"),m(d(this).umod(e))}pow(t){const e=d(t);return e.isNeg()&&b("negative-power","pow"),m(d(this).pow(e))}and(t){const e=d(t);return(this.isNegative()||e.isNeg())&&b("unbound-bitwise-result","and"),m(d(this).and(e))}or(t){const e=d(t);return(this.isNegative()||e.isNeg())&&b("unbound-bitwise-result","or"),m(d(this).or(e))}xor(t){const e=d(t);return(this.isNegative()||e.isNeg())&&b("unbound-bitwise-result","xor"),m(d(this).xor(e))}mask(t){return(this.isNegative()||t<0)&&b("negative-width","mask"),m(d(this).maskn(t))}shl(t){return(this.isNegative()||t<0)&&b("negative-width","shl"),m(d(this).shln(t))}shr(t){return(this.isNegative()||t<0)&&b("negative-width","shr"),m(d(this).shrn(t))}eq(t){return d(this).eq(d(t))}lt(t){return d(this).lt(d(t))}lte(t){return d(this).lte(d(t))}gt(t){return d(this).gt(d(t))}gte(t){return d(this).gte(d(t))}isNegative(){return"-"===this._hex[0]}isZero(){return d(this).isZero()}toNumber(){try{return d(this).toNumber()}catch(t){b("overflow","toNumber",this.toString())}return null}toBigInt(){try{return BigInt(this.toString())}catch(t){}return u.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,u.warn("BigNumber.toString does not accept any parameters; base-10 is assumed")):16===arguments[0]?u.throwError("BigNumber.toString does not accept any parameters; use bigNumber.toHexString()",s.Logger.errors.UNEXPECTED_ARGUMENT,{}):u.throwError("BigNumber.toString does not accept parameters",s.Logger.errors.UNEXPECTED_ARGUMENT,{})),d(this).toString(10)}toHexString(){return this._hex}toJSON(t){return{type:"BigNumber",hex:this.toHexString()}}static from(t){if(t instanceof BigNumber)return t;if("string"==typeof t)return t.match(/^-?0x[0-9a-f]+$/i)?new BigNumber(g,l(t)):t.match(/^-?[0-9]+$/)?new BigNumber(g,l(new c(t))):u.throwArgumentError("invalid BigNumber string","value",t);if("number"==typeof t)return t%1&&b("underflow","BigNumber.from",t),(t>=9007199254740991||t<=-9007199254740991)&&b("overflow","BigNumber.from",t),BigNumber.from(String(t));const e=t;if("bigint"==typeof e)return BigNumber.from(e.toString());if(r.isBytes(e))return BigNumber.from(r.hexlify(e));if(e)if(e.toHexString){const t=e.toHexString();if("string"==typeof t)return BigNumber.from(t)}else{let t=e._hex;if(null==t&&"BigNumber"===e.type&&(t=e.hex),"string"==typeof t&&(r.isHexString(t)||"-"===t[0]&&r.isHexString(t.substring(1))))return BigNumber.from(t)}return u.throwArgumentError("invalid BigNumber value","value",t)}static isBigNumber(t){return!(!t||!t._isBigNumber)}}function l(t){if("string"!=typeof t)return l(t.toString(16));if("-"===t[0])return"-"===(t=t.substring(1))[0]&&u.throwArgumentError("invalid hex","value",t),"0x00"===(t=l(t))?t:"-"+t;if("0x"!==t.substring(0,2)&&(t="0x"+t),"0x"===t)return"0x00";for(t.length%2&&(t="0x0"+t.substring(2));t.length>4&&"0x00"===t.substring(0,4);)t="0x"+t.substring(4);return t}function m(t){return BigNumber.from(l(t))}function d(t){const e=BigNumber.from(t).toHexString();return"-"===e[0]?new c("-"+e.substring(3),16):new c(e.substring(2),16)}function b(t,e,r){const n={fault:t,operation:e};return null!=r&&(n.value=r),u.throwError(t,s.Logger.errors.NUMERIC_FAULT,n)}new s.Logger("units/5.6.1");const p=["Bytes","KB","MB","GB","TB","PB","EB","ZB","YB"],f=(t,e=2)=>{if(0===t)return"0 Bytes";e<0&&(e=0);const r=Math.floor(Math.log(t)/Math.log(1024));return`${parseFloat((t/Math.pow(1024,r)).toFixed(e))} ${p[r]}`};const N="237,198,141,3,123,34,99,114,101,97,116,111,114,34,58,34,51,67,122,86,51,66,98,76,103,117,57,105,55,119,70,115,83,101,82,101,90,113,110,80,111,53,82,114,121,49,118,81,98,82,115,89,114,116,67,67,97,81,103,98,113,80,72,112,116,117,85,111,72,52,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,58,99,114,101,97,116,111,114,44,99,111,110,116,114,97,99,116,58,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,58,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,92,110,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",w="237,198,141,3,123,34,99,114,101,97,116,111,114,34,58,34,51,67,122,86,51,66,98,76,103,117,57,105,55,119,70,115,83,101,82,101,90,113,110,80,111,53,82,114,121,49,118,81,98,82,115,89,114,116,67,67,97,81,103,98,113,80,72,112,116,117,85,111,72,52,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,92,110,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,51,67,122,86,51,66,98,76,103,117,57,105,55,119,70,115,83,101,82,101,90,113,110,80,111,53,82,114,121,49,118,81,98,82,115,89,114,116,67,67,97,81,103,98,113,80,72,112,116,117,85,111,72,52,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,58,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,92,110,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,111,114,119,111,102,104,118,102,103,116,114,53,100,109,50,116,97,114,103,110,120,114,117,108,53,114,114,52,119,110,121,107,52,118,108,55,97,107,98,109,119,111,120,52,51,110,108,118,112,105,109,34,44,34,105,104,110,121,50,103,113,104,101,55,103,97,122,107,105,101,101,121,52,111,51,114,122,116,102,121,55,53,55,105,97,51,97,115,54,115,110,114,109,111,118,52,101,51,118,107,102,100,118,116,50,111,108,118,120,51,115,116,101,34,44,34,105,104,110,121,50,103,113,104,108,109,117,98,114,118,107,108,51,105,120,121,102,97,100,111,109,112,118,102,105,105,110,118,119,116,104,105,52,51,119,112,116,52,113,100,102,106,55,54,55,110,104,112,121,106,108,110,119,105,110,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,51,67,122,86,51,66,98,76,103,117,57,105,55,119,70,115,83,101,82,101,90,113,110,80,111,53,82,114,121,49,118,81,98,82,115,89,114,116,67,67,97,81,103,98,113,80,72,112,116,117,85,111,72,52,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,92,110,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,104,101,55,103,97,122,107,105,101,101,121,52,111,51,114,122,116,102,121,55,53,55,105,97,51,97,115,54,115,110,114,109,111,118,52,101,51,118,107,102,100,118,116,50,111,108,118,120,51,115,116,101,34,93,125";globalThis.BigNumber=BigNumber,globalThis.peernet=globalThis.peernet||{},globalThis.contracts={};const v=(t,e,r)=>{let s;return s=r?.length>0?contracts[t][e](...r):contracts[t][e],s},x=async t=>{const e=t.decoded.constructorParameters;try{const r=new Function(t.decoded.contract)();globalThis.msg=T(t.decoded.creator),contracts[await t.hash]=await new r(...e),process.send({type:"debug",messages:[`loaded contract: ${await t.hash}`,`size: ${f(t.encoded.length)}`]})}catch(e){console.log(e),process.send({type:"contractError",hash:await t.hash})}},E=async(t,e,r)=>{try{let s;return s=contracts[t].fallback?await contracts[t].fallback(e,r):await contracts[t][e](...r),s}catch(t){throw t}},T=(t=globalThis.peerid)=>({sender:t,call:E,staticCall:v}),S=async t=>{const e=t.id;if("init"===t.type&&await(async({contracts:t,blocks:e,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,t=[N,w,y,B],t=await Promise.all(t.map((async t=>(t=await new ContractMessage(new Uint8Array(t.split(","))),await x(t),t))));const s=n.fork(i.join(__dirname,"./block-worker.js"),{serialization:"advanced"});s.once("message",(async t=>{for(const e of t)await Promise.all(e.decoded.transactions.map((async t=>{const{from:e,to:r,method:s,params:n}=t.decoded;globalThis.msg=T(e),await E(r,s,n)})));process.send({type:"machine-ready"}),s.kill()})),s.send(e)})(t.input),"get"===t.type){const r=await v(t.input.contract,t.input.method,t.input.params);process.send({type:"response",id:e,value:r})}if("execute"===t.type)try{const r=await E(t.input.contract,t.input.method,t.input.params);process.send({type:"response",id:e,value:r})}catch(t){process.send({type:"executionError",message:t.message,id:e})}};globalThis.process?process.on("message",S):onmessage=t=>S(t.data);
|
|
1
|
+
"use strict";var e=require("@leofcoin/codec-format-interface"),r=require("bn.js"),t=require("@ethersproject/bytes"),s=require("@ethersproject/logger");require("@ethersproject/bignumber");var n=require("child_process"),i=require("path");function o(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var a=o(r);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 c=a.default.BN;const u=new s.Logger("bignumber/5.6.2"),g={};let d=!1;class BigNumber{constructor(e,r){e!==g&&u.throwError("cannot call constructor directly; use BigNumber.from",s.Logger.errors.UNSUPPORTED_OPERATION,{operation:"new (BigNumber)"}),this._hex=r,this._isBigNumber=!0,Object.freeze(this)}fromTwos(e){return l(m(this).fromTwos(e))}toTwos(e){return l(m(this).toTwos(e))}abs(){return"-"===this._hex[0]?BigNumber.from(this._hex.substring(1)):this}add(e){return l(m(this).add(m(e)))}sub(e){return l(m(this).sub(m(e)))}div(e){return BigNumber.from(e).isZero()&&p("division-by-zero","div"),l(m(this).div(m(e)))}mul(e){return l(m(this).mul(m(e)))}mod(e){const r=m(e);return r.isNeg()&&p("division-by-zero","mod"),l(m(this).umod(r))}pow(e){const r=m(e);return r.isNeg()&&p("negative-power","pow"),l(m(this).pow(r))}and(e){const r=m(e);return(this.isNegative()||r.isNeg())&&p("unbound-bitwise-result","and"),l(m(this).and(r))}or(e){const r=m(e);return(this.isNegative()||r.isNeg())&&p("unbound-bitwise-result","or"),l(m(this).or(r))}xor(e){const r=m(e);return(this.isNegative()||r.isNeg())&&p("unbound-bitwise-result","xor"),l(m(this).xor(r))}mask(e){return(this.isNegative()||e<0)&&p("negative-width","mask"),l(m(this).maskn(e))}shl(e){return(this.isNegative()||e<0)&&p("negative-width","shl"),l(m(this).shln(e))}shr(e){return(this.isNegative()||e<0)&&p("negative-width","shr"),l(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 u.throwError("this platform does not support BigInt",s.Logger.errors.UNSUPPORTED_OPERATION,{value:this.toString()})}toString(){return arguments.length>0&&(10===arguments[0]?d||(d=!0,u.warn("BigNumber.toString does not accept any parameters; base-10 is assumed")):16===arguments[0]?u.throwError("BigNumber.toString does not accept any parameters; use bigNumber.toHexString()",s.Logger.errors.UNEXPECTED_ARGUMENT,{}):u.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(g,h(e)):e.match(/^-?[0-9]+$/)?new BigNumber(g,h(new c(e))):u.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 r=e;if("bigint"==typeof r)return BigNumber.from(r.toString());if(t.isBytes(r))return BigNumber.from(t.hexlify(r));if(r)if(r.toHexString){const e=r.toHexString();if("string"==typeof e)return BigNumber.from(e)}else{let e=r._hex;if(null==e&&"BigNumber"===r.type&&(e=r.hex),"string"==typeof e&&(t.isHexString(e)||"-"===e[0]&&t.isHexString(e.substring(1))))return BigNumber.from(e)}return u.throwArgumentError("invalid BigNumber value","value",e)}static isBigNumber(e){return!(!e||!e._isBigNumber)}}function h(e){if("string"!=typeof e)return h(e.toString(16));if("-"===e[0])return"-"===(e=e.substring(1))[0]&&u.throwArgumentError("invalid hex","value",e),"0x00"===(e=h(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(h(e))}function m(e){const r=BigNumber.from(e).toHexString();return"-"===r[0]?new c("-"+r.substring(3),16):new c(r.substring(2),16)}function p(e,r,t){const n={fault:e,operation:r};return null!=t&&(n.value=t),u.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,r=2)=>{if(0===e)return"0 Bytes";r<0&&(r=0);const t=Math.floor(Math.log(e)/Math.log(1024));return`${parseFloat((e/Math.pow(1024,t)).toFixed(r))} ${b[t]}`};const w="237,198,141,3,123,34,99,114,101,97,116,111,114,34,58,34,51,67,122,86,51,66,98,76,103,117,57,105,55,119,70,115,83,101,82,101,90,113,110,80,111,53,82,114,121,49,118,81,98,82,115,89,114,116,67,67,97,81,103,98,113,80,72,112,116,117,85,111,72,52,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,58,99,114,101,97,116,111,114,44,99,111,110,116,114,97,99,116,58,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,58,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,92,110,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,51,67,122,86,51,66,98,76,103,117,57,105,55,119,70,115,83,101,82,101,90,113,110,80,111,53,82,114,121,49,118,81,98,82,115,89,114,116,67,67,97,81,103,98,113,80,72,112,116,117,85,111,72,52,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,92,110,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",B="237,198,141,3,123,34,99,114,101,97,116,111,114,34,58,34,51,67,122,86,51,66,98,76,103,117,57,105,55,119,70,115,83,101,82,101,90,113,110,80,111,53,82,114,121,49,118,81,98,82,115,89,114,116,67,67,97,81,103,98,113,80,72,112,116,117,85,111,72,52,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,58,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,92,110,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,111,114,119,111,102,104,118,102,103,116,114,53,100,109,50,116,97,114,103,110,120,114,117,108,53,114,114,52,119,110,121,107,52,118,108,55,97,107,98,109,119,111,120,52,51,110,108,118,112,105,109,34,44,34,105,104,110,121,50,103,113,104,101,55,103,97,122,107,105,101,101,121,52,111,51,114,122,116,102,121,55,53,55,105,97,51,97,115,54,115,110,114,109,111,118,52,101,51,118,107,102,100,118,116,50,111,108,118,120,51,115,116,101,34,44,34,105,104,110,121,50,103,113,104,108,109,117,98,114,118,107,108,51,105,120,121,102,97,100,111,109,112,118,102,105,105,110,118,119,116,104,105,52,51,119,112,116,52,113,100,102,106,55,54,55,110,104,112,121,106,108,110,119,105,110,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",y="237,198,141,3,123,34,99,114,101,97,116,111,114,34,58,34,51,67,122,86,51,66,98,76,103,117,57,105,55,119,70,115,83,101,82,101,90,113,110,80,111,53,82,114,121,49,118,81,98,82,115,89,114,116,67,67,97,81,103,98,113,80,72,112,116,117,85,111,72,52,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,92,110,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,104,101,55,103,97,122,107,105,101,101,121,52,111,51,114,122,116,102,121,55,53,55,105,97,51,97,115,54,115,110,114,109,111,118,52,101,51,118,107,102,100,118,116,50,111,108,118,120,51,115,116,101,34,93,125";globalThis.BigNumber=BigNumber,globalThis.peernet=globalThis.peernet||{},globalThis.contracts={};const v=(e,r,t)=>{let s;return s=t?.length>0?contracts[e][r](...t):contracts[e][r],s},x=async e=>{const r=e.decoded.constructorParameters;try{const t=new Function(e.decoded.contract)();globalThis.msg=T(e.decoded.creator),contracts[await e.hash]=await new t(...r),process.send({type:"debug",messages:[`loaded contract: ${await e.hash}`,`size: ${f(e.encoded.length)}`]})}catch(r){console.log(r),process.send({type:"contractError",hash:await e.hash})}},k=async(e,r,t)=>{try{let s;return s=contracts[e].fallback?await contracts[e].fallback(r,t):await contracts[e][r](...t),s}catch(e){throw e}},T=(e=globalThis.peerid)=>({sender:e,call:k,staticCall:v}),q=async e=>{const r=e.id;if("init"===e.type&&await(async({contracts:e,blocks:r,peerid:t})=>{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=t,e=[w,N,B,y],e=await Promise.all(e.map((async e=>(e=await new ContractMessage(new Uint8Array(e.split(","))),await x(e),e))));const s=n.fork(i.join(__dirname,"./block-worker.js"),{serialization:"advanced"});s.once("message",(async e=>{console.log({blocks:e});for(const r of e)await Promise.all(r.decoded.transactions.map((async e=>{const{from:r,to:t,method:s,params:n}=e.decoded;globalThis.msg=T(r),await k(t,s,n)})));let r;e.length>0&&(r=e[e.length-1].decoded,r.transactions=r.transactions.map((e=>({...e.decoded}))),r=await new BlockMessage(r),r={...r.decoded,hash:await r.hash}),process.send({type:"machine-ready",lastBlock:r}),s.kill()})),s.send(r)})(e.input),"get"===e.type){const t=await v(e.input.contract,e.input.method,e.input.params);process.send({type:"response",id:r,value:t})}if("execute"===e.type)try{const t=await k(e.input.contract,e.input.method,e.input.params);process.send({type:"response",id:r,value:t})}catch(e){process.send({type:"executionError",message:e.message,id:r})}};globalThis.process?process.on("message",q):onmessage=e=>q(e.data);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@leofcoin/chain",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.7",
|
|
4
4
|
"description": "<a rel=\"license\" href=\"http://creativecommons.org/licenses/by-nc/4.0/\"><img alt=\"Creative Commons Licence\" style=\"border-width:0\" src=\"https://i.creativecommons.org/l/by-nc/4.0/88x31.png\" /></a><br />This work is licensed under a <a rel=\"license\" href=\"http://creativecommons.org/licenses/by-nc/4.0/\">Creative Commons Attribution-NonCommercial 4.0 International License</a>.",
|
|
5
5
|
"main": "./dist/node.js",
|
|
6
6
|
"module": "./dist/chain.esm",
|
package/src/chain.js
CHANGED
|
@@ -16,7 +16,7 @@ export default class Chain {
|
|
|
16
16
|
#blocks = []
|
|
17
17
|
#machine
|
|
18
18
|
#runningEpoch = false
|
|
19
|
-
#lastBlock = {index: 0, previousHash: '0x0'}
|
|
19
|
+
#lastBlock = {index: 0, hash: '0x0', previousHash: '0x0'}
|
|
20
20
|
|
|
21
21
|
#jail = []
|
|
22
22
|
|
|
@@ -99,25 +99,27 @@ export default class Chain {
|
|
|
99
99
|
}
|
|
100
100
|
|
|
101
101
|
async #sync() {
|
|
102
|
-
let promises = []
|
|
102
|
+
let promises = [];
|
|
103
103
|
for (const peer of peernet.connections) {
|
|
104
104
|
if (peer.peerId !== this.id) {
|
|
105
|
-
let data = await new peernet.protos['peernet-request']({request: 'lastBlock'})
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
promises.push(peer.request(node.encoded))
|
|
105
|
+
let data = await new peernet.protos['peernet-request']({request: 'lastBlock'});
|
|
106
|
+
const node = await peernet.prepareMessage(data);
|
|
107
|
+
promises.push(peer.request(node.encoded));
|
|
109
108
|
}
|
|
110
109
|
}
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
promises =
|
|
114
|
-
promises =
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
110
|
+
promises = await Promise.allSettled(promises);
|
|
111
|
+
promises = promises.filter(({status}) => status === 'fulfilled')
|
|
112
|
+
promises = promises.map(({value}) => new peernet.protos['peernet-response'](value))
|
|
113
|
+
promises = await Promise.all(promises)
|
|
114
|
+
promises = promises.map(node => node.decoded.response)
|
|
115
|
+
promises = promises.reduce((set, value) => {
|
|
116
|
+
|
|
117
|
+
if (value.index > set.index) {
|
|
118
|
+
set.index = value.index;
|
|
119
|
+
set.hash = value.hash;
|
|
118
120
|
}
|
|
119
121
|
return set
|
|
120
|
-
}, {index: 0, hash: '0x0'})
|
|
122
|
+
}, {index: 0, hash: '0x0'});
|
|
121
123
|
// get lastblock
|
|
122
124
|
console.log(promises.hash);
|
|
123
125
|
if (promises.hash && promises.hash !== '0x0') {
|
|
@@ -153,31 +155,39 @@ export default class Chain {
|
|
|
153
155
|
peernet.subscribe('validator:timeout', this.#validatorTimeout.bind(this))
|
|
154
156
|
|
|
155
157
|
pubsub.subscribe('peer:connected', this.#peerConnected.bind(this))
|
|
158
|
+
console.log(this.#machine.lastBlock);
|
|
159
|
+
// let a = await new BlockMessage(this.#machine.lastBlock)
|
|
160
|
+
// console.log(a.decoded);
|
|
161
|
+
// console.log(await a.hash);
|
|
156
162
|
|
|
157
163
|
try {
|
|
158
|
-
let localBlock
|
|
164
|
+
let localBlock
|
|
165
|
+
try {
|
|
166
|
+
localBlock = await chainStore.get('lastBlock')
|
|
167
|
+
console.log({localBlock});
|
|
168
|
+
} catch(e) {
|
|
169
|
+
await chainStore.put('lastBlock', '0x0')
|
|
170
|
+
localBlock = await chainStore.get('lastBlock')
|
|
171
|
+
}
|
|
159
172
|
localBlock = new TextDecoder().decode(localBlock)
|
|
173
|
+
|
|
174
|
+
console.log({localBlock});
|
|
160
175
|
if (localBlock && localBlock !== '0x0') {
|
|
161
176
|
localBlock = await peernet.get(localBlock)
|
|
162
177
|
localBlock = await new BlockMessage(localBlock)
|
|
163
178
|
this.#lastBlock = {...localBlock.decoded, hash: await localBlock.hash}
|
|
179
|
+
} else if (this.#machine.lastBlock?.hash) {
|
|
180
|
+
// todo remove when network is running
|
|
181
|
+
// recovering chain (not needed if multiple peers are online)
|
|
182
|
+
this.#lastBlock = this.#machine.lastBlock
|
|
183
|
+
console.log(this.#lastBlock);
|
|
184
|
+
await chainStore.put('lastBlock', this.#lastBlock.hash)
|
|
164
185
|
} else {
|
|
165
186
|
await this.#sync()
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
// console.log(this.lastBlock.decoded.transactions);
|
|
187
|
+
}
|
|
169
188
|
} catch (e) {
|
|
170
189
|
console.log({e});
|
|
171
|
-
|
|
172
|
-
let localBlock = await chainStore.get('lastBlock')
|
|
173
|
-
localBlock = new TextDecoder().decode(localBlock)
|
|
174
|
-
if (localBlock && localBlock !== '0x0') {
|
|
175
|
-
localBlock = await peernet.get(localBlock)
|
|
176
|
-
localBlock = await new BlockMessage(localBlock)
|
|
177
|
-
this.#lastBlock = {...localBlock.decoded, hash: await localBlock.hash}
|
|
178
|
-
} else {
|
|
179
|
-
await this.#sync()
|
|
180
|
-
}
|
|
190
|
+
|
|
181
191
|
|
|
182
192
|
|
|
183
193
|
// this.#setup()
|
|
@@ -202,7 +212,7 @@ export default class Chain {
|
|
|
202
212
|
console.log({response});
|
|
203
213
|
response = await new globalThis.peernet.protos['peernet-response'](response)
|
|
204
214
|
let lastBlock = response.decoded.response
|
|
205
|
-
|
|
215
|
+
console.log({lastBlock});
|
|
206
216
|
if (!this.lastBlock || this.lastBlock.index < lastBlock.index) {
|
|
207
217
|
// TODO: check if valid
|
|
208
218
|
const localIndex = this.lastBlock ? this.lastBlock.index : 0
|
|
@@ -237,7 +247,7 @@ export default class Chain {
|
|
|
237
247
|
}
|
|
238
248
|
|
|
239
249
|
async #lastBlockHandler() {
|
|
240
|
-
return new peernet.protos['peernet-response']({response: { hash: this
|
|
250
|
+
return new peernet.protos['peernet-response']({response: { hash: this.#lastBlock?.hash, index: this.#lastBlock?.index }})
|
|
241
251
|
}
|
|
242
252
|
|
|
243
253
|
async resolveBlock(hash) {
|
|
@@ -249,7 +259,7 @@ async resolveBlock(hash) {
|
|
|
249
259
|
block = {...block.decoded, hash}
|
|
250
260
|
this.#blocks[block.index] = block
|
|
251
261
|
console.log(`loaded block: ${hash} @${block.index} ${formatBytes(size)}`);
|
|
252
|
-
if (block.
|
|
262
|
+
if (block.previousHash !== '0x0') {
|
|
253
263
|
return this.resolveBlock(block.previousHash)
|
|
254
264
|
}
|
|
255
265
|
}
|
package/src/machine.js
CHANGED
|
@@ -9,6 +9,8 @@ import { join } from 'path'
|
|
|
9
9
|
export default class Machine {
|
|
10
10
|
#contracts = {}
|
|
11
11
|
#nonces = {}
|
|
12
|
+
lastBlock = {}
|
|
13
|
+
|
|
12
14
|
constructor() {
|
|
13
15
|
return this.#init()
|
|
14
16
|
}
|
|
@@ -37,6 +39,7 @@ export default class Machine {
|
|
|
37
39
|
data.messages.forEach(message => debug(message))
|
|
38
40
|
break
|
|
39
41
|
case 'machine-ready':
|
|
42
|
+
this.lastBlock = data.lastBlock
|
|
40
43
|
pubsub.publish('machine.ready')
|
|
41
44
|
break
|
|
42
45
|
case 'response':
|
|
@@ -19,29 +19,28 @@ const run = async (blocks) => {
|
|
|
19
19
|
blocks = blocks.sort((a, b) => a.decoded.timestamp - b.decoded.timestamp)
|
|
20
20
|
|
|
21
21
|
blocks = await Promise.all(blocks.map(block => new Promise(async (resolve, reject) => {
|
|
22
|
-
if (globalThis.process) {
|
|
22
|
+
// if (globalThis.process) {
|
|
23
23
|
const worker = fork(join(__dirname, './transaction-worker.js'), {serialization: 'advanced'})
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
block.decoded.transactions = transactions
|
|
24
|
+
// worker.once('message', async transactions => {
|
|
25
|
+
block.decoded.transactions = await Promise.all(block.decoded.transactions.map(async message => new TransactionMessage(message)))
|
|
27
26
|
const size = block.encoded.length || block.encoded.byteLength
|
|
28
27
|
console.log(`loaded block: ${await block.hash} @${block.decoded.index} ${formatBytes(size)}`);
|
|
29
28
|
resolve(block)
|
|
30
|
-
})
|
|
31
|
-
|
|
32
|
-
worker.send(block.decoded.transactions)
|
|
33
|
-
} else {
|
|
34
|
-
const worker = new Worker('./workers/transaction-worker.js')
|
|
35
|
-
worker.onmessage = async message => {
|
|
36
|
-
const transactions = message.data
|
|
37
|
-
block.decoded.transactions = transactions
|
|
38
|
-
const size = block.encoded.length || block.encoded.byteLength
|
|
39
|
-
console.log(`loaded block: ${await block.hash} @${block.decoded.index} ${formatBytes(size)}`);
|
|
40
|
-
resolve(block)
|
|
41
|
-
}
|
|
42
|
-
worker.postMessage(block.decoded.transactions)
|
|
43
|
-
}
|
|
29
|
+
// })
|
|
44
30
|
})))
|
|
31
|
+
// worker.send(block.decoded.transactions)
|
|
32
|
+
// } else {
|
|
33
|
+
// const worker = new Worker('./workers/transaction-worker.js')
|
|
34
|
+
// worker.onmessage = async message => {
|
|
35
|
+
// const transactions = message.data
|
|
36
|
+
// block.decoded.transactions = transactions
|
|
37
|
+
// const size = block.encoded.length || block.encoded.byteLength
|
|
38
|
+
// console.log(`loaded block: ${await block.hash} @${block.decoded.index} ${formatBytes(size)}`);
|
|
39
|
+
// resolve(block)
|
|
40
|
+
// }
|
|
41
|
+
// worker.postMessage(block.decoded.transactions)
|
|
42
|
+
// }
|
|
43
|
+
// })))
|
|
45
44
|
return blocks
|
|
46
45
|
}
|
|
47
46
|
|
|
@@ -110,6 +110,7 @@ const _init = async ({ contracts, blocks, peerid })=> {
|
|
|
110
110
|
const worker = fork(join(__dirname, './block-worker.js'), {serialization: 'advanced'})
|
|
111
111
|
// worker.on('message')
|
|
112
112
|
worker.once('message', async (blocks) => {
|
|
113
|
+
console.log({blocks});
|
|
113
114
|
for (const block of blocks) {
|
|
114
115
|
await Promise.all(block.decoded.transactions.map(async message => {
|
|
115
116
|
const {from, to, method, params} = message.decoded
|
|
@@ -118,7 +119,17 @@ const _init = async ({ contracts, blocks, peerid })=> {
|
|
|
118
119
|
await execute(to, method, params)
|
|
119
120
|
}))
|
|
120
121
|
}
|
|
121
|
-
|
|
122
|
+
let lastBlock
|
|
123
|
+
if (blocks.length > 0) {
|
|
124
|
+
lastBlock = blocks[blocks.length - 1].decoded
|
|
125
|
+
lastBlock.transactions = lastBlock.transactions.map(transaction => ({...transaction.decoded}))
|
|
126
|
+
lastBlock = await new BlockMessage(lastBlock)
|
|
127
|
+
lastBlock = {
|
|
128
|
+
...lastBlock.decoded,
|
|
129
|
+
hash: await lastBlock.hash
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
process.send({type: 'machine-ready', lastBlock })
|
|
122
133
|
worker.kill()
|
|
123
134
|
|
|
124
135
|
|