@leofcoin/chain 1.1.13 → 1.3.0
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/block-worker.js +1 -1
- package/demo/chain.browser.js +8 -8
- package/demo/node.browser.js +35 -9
- package/demo/peernet-swarm.browser.js +22 -10
- package/demo/workers/block-worker.js +155 -179
- package/demo/workers/machine-worker.js +184 -208
- package/dist/browser/workers/block-worker.js +155 -179
- package/dist/browser/workers/machine-worker.js +184 -208
- package/dist/chain.browser.js +8 -8
- package/dist/chain.js +8 -8
- package/dist/contracts/factory.js +1 -1
- package/dist/contracts/nameService.js +1 -1
- package/dist/contracts/nativeToken.js +1 -1
- package/dist/module/chain.js +8 -8
- package/dist/module/node.js +22 -7
- package/dist/module/workers/block-worker.js +287 -2
- package/dist/module/workers/machine-worker.js +291 -6
- package/dist/node.browser.js +35 -9
- package/dist/node.js +22 -7
- package/dist/peernet-swarm.browser.js +22 -10
- package/dist/standards/token.js +1 -1
- package/dist/workers/machine-worker.js +1 -1
- package/package.json +6 -5
- package/rollup.config.js +22 -13
- package/src/node.js +6 -4
- package/test/chain.js +23 -20
- package/.jsdoc.json +0 -29
|
@@ -12323,12 +12323,12 @@ function addSlice(array) {
|
|
|
12323
12323
|
return array;
|
|
12324
12324
|
}
|
|
12325
12325
|
function isBytesLike(value) {
|
|
12326
|
-
return ((
|
|
12326
|
+
return ((isHexString(value) && !(value.length % 2)) || isBytes(value));
|
|
12327
12327
|
}
|
|
12328
12328
|
function isInteger(value) {
|
|
12329
12329
|
return (typeof (value) === "number" && value == value && (value % 1) === 0);
|
|
12330
12330
|
}
|
|
12331
|
-
function
|
|
12331
|
+
function isBytes(value) {
|
|
12332
12332
|
if (value == null) {
|
|
12333
12333
|
return false;
|
|
12334
12334
|
}
|
|
@@ -12371,7 +12371,7 @@ function arrayify(value, options) {
|
|
|
12371
12371
|
if (isHexable(value)) {
|
|
12372
12372
|
value = value.toHexString();
|
|
12373
12373
|
}
|
|
12374
|
-
if (
|
|
12374
|
+
if (isHexString(value)) {
|
|
12375
12375
|
let hex = value.substring(2);
|
|
12376
12376
|
if (hex.length % 2) {
|
|
12377
12377
|
if (options.hexPad === "left") {
|
|
@@ -12390,7 +12390,7 @@ function arrayify(value, options) {
|
|
|
12390
12390
|
}
|
|
12391
12391
|
return addSlice(new Uint8Array(result));
|
|
12392
12392
|
}
|
|
12393
|
-
if (
|
|
12393
|
+
if (isBytes(value)) {
|
|
12394
12394
|
return addSlice(new Uint8Array(value));
|
|
12395
12395
|
}
|
|
12396
12396
|
return logger.throwArgumentError("invalid arrayify value", "value", value);
|
|
@@ -12430,7 +12430,7 @@ function zeroPad(value, length) {
|
|
|
12430
12430
|
result.set(value, length - value.length);
|
|
12431
12431
|
return addSlice(result);
|
|
12432
12432
|
}
|
|
12433
|
-
function
|
|
12433
|
+
function isHexString(value, length) {
|
|
12434
12434
|
if (typeof (value) !== "string" || !value.match(/^0x[0-9A-Fa-f]*$/)) {
|
|
12435
12435
|
return false;
|
|
12436
12436
|
}
|
|
@@ -12472,7 +12472,7 @@ function hexlify(value, options) {
|
|
|
12472
12472
|
if (isHexable(value)) {
|
|
12473
12473
|
return value.toHexString();
|
|
12474
12474
|
}
|
|
12475
|
-
if (
|
|
12475
|
+
if (isHexString(value)) {
|
|
12476
12476
|
if (value.length % 2) {
|
|
12477
12477
|
if (options.hexPad === "left") {
|
|
12478
12478
|
value = "0x0" + value.substring(2);
|
|
@@ -12486,7 +12486,7 @@ function hexlify(value, options) {
|
|
|
12486
12486
|
}
|
|
12487
12487
|
return value.toLowerCase();
|
|
12488
12488
|
}
|
|
12489
|
-
if (
|
|
12489
|
+
if (isBytes(value)) {
|
|
12490
12490
|
let result = "0x";
|
|
12491
12491
|
for (let i = 0; i < value.length; i++) {
|
|
12492
12492
|
let v = value[i];
|
|
@@ -12508,7 +12508,7 @@ function hexDataLength(data) {
|
|
|
12508
12508
|
if (typeof (data) !== "string") {
|
|
12509
12509
|
data = hexlify(data);
|
|
12510
12510
|
}
|
|
12511
|
-
else if (!
|
|
12511
|
+
else if (!isHexString(data) || (data.length % 2)) {
|
|
12512
12512
|
return null;
|
|
12513
12513
|
}
|
|
12514
12514
|
return (data.length - 2) / 2;
|
|
@@ -12517,7 +12517,7 @@ function hexDataSlice(data, offset, endOffset) {
|
|
|
12517
12517
|
if (typeof (data) !== "string") {
|
|
12518
12518
|
data = hexlify(data);
|
|
12519
12519
|
}
|
|
12520
|
-
else if (!
|
|
12520
|
+
else if (!isHexString(data) || (data.length % 2)) {
|
|
12521
12521
|
logger.throwArgumentError("invalid hexData", "value", data);
|
|
12522
12522
|
}
|
|
12523
12523
|
offset = 2 + 2 * offset;
|
|
@@ -12544,7 +12544,7 @@ function hexStripZeros(value) {
|
|
|
12544
12544
|
if (typeof (value) !== "string") {
|
|
12545
12545
|
value = hexlify(value);
|
|
12546
12546
|
}
|
|
12547
|
-
if (!
|
|
12547
|
+
if (!isHexString(value)) {
|
|
12548
12548
|
logger.throwArgumentError("invalid hex string", "value", value);
|
|
12549
12549
|
}
|
|
12550
12550
|
value = value.substring(2);
|
|
@@ -12558,7 +12558,7 @@ function hexZeroPad(value, length) {
|
|
|
12558
12558
|
if (typeof (value) !== "string") {
|
|
12559
12559
|
value = hexlify(value);
|
|
12560
12560
|
}
|
|
12561
|
-
else if (!
|
|
12561
|
+
else if (!isHexString(value)) {
|
|
12562
12562
|
logger.throwArgumentError("invalid hex string", "value", value);
|
|
12563
12563
|
}
|
|
12564
12564
|
if (value.length > 2 * length + 2) {
|
|
@@ -12666,13 +12666,13 @@ function splitSignature(signature) {
|
|
|
12666
12666
|
}
|
|
12667
12667
|
}
|
|
12668
12668
|
}
|
|
12669
|
-
if (result.r == null || !
|
|
12669
|
+
if (result.r == null || !isHexString(result.r)) {
|
|
12670
12670
|
logger.throwArgumentError("signature missing or invalid r", "signature", signature);
|
|
12671
12671
|
}
|
|
12672
12672
|
else {
|
|
12673
12673
|
result.r = hexZeroPad(result.r, 32);
|
|
12674
12674
|
}
|
|
12675
|
-
if (result.s == null || !
|
|
12675
|
+
if (result.s == null || !isHexString(result.s)) {
|
|
12676
12676
|
logger.throwArgumentError("signature missing or invalid s", "signature", signature);
|
|
12677
12677
|
}
|
|
12678
12678
|
else {
|
|
@@ -12687,7 +12687,7 @@ function splitSignature(signature) {
|
|
|
12687
12687
|
}
|
|
12688
12688
|
const _vs = hexlify(vs);
|
|
12689
12689
|
if (result._vs) {
|
|
12690
|
-
if (!
|
|
12690
|
+
if (!isHexString(result._vs)) {
|
|
12691
12691
|
logger.throwArgumentError("signature invalid _vs", "signature", signature);
|
|
12692
12692
|
}
|
|
12693
12693
|
result._vs = hexZeroPad(result._vs, 32);
|
|
@@ -12713,40 +12713,147 @@ function joinSignature(signature) {
|
|
|
12713
12713
|
]));
|
|
12714
12714
|
}
|
|
12715
12715
|
//# sourceMappingURL=index.js.map
|
|
12716
|
-
;// CONCATENATED MODULE: ./node_modules/@
|
|
12717
|
-
|
|
12718
|
-
|
|
12719
|
-
|
|
12716
|
+
;// CONCATENATED MODULE: ./node_modules/@vandeurenglenn/easy-worker/src/worker.js
|
|
12717
|
+
/* provided dependency */ var process = __webpack_require__(155);
|
|
12718
|
+
class EasyWorker {
|
|
12719
|
+
#messageEvent = 'message'
|
|
12720
|
+
#errorEvent = 'error'
|
|
12721
|
+
#isBrowser = false
|
|
12722
|
+
#isWorker = false
|
|
12723
|
+
|
|
12724
|
+
get isWorker() {
|
|
12725
|
+
return this.#isWorker
|
|
12726
|
+
}
|
|
12727
|
+
constructor(url, options) {
|
|
12728
|
+
return this.#init(url, options)
|
|
12729
|
+
}
|
|
12730
|
+
|
|
12731
|
+
#init(url, options = {}) {
|
|
12732
|
+
if (url) {
|
|
12733
|
+
if (globalThis.Worker) {
|
|
12734
|
+
this.#isBrowser = true
|
|
12735
|
+
this.worker = new Worker(url, {...options})
|
|
12736
|
+
} else {
|
|
12737
|
+
return new Promise(async (resolve, reject) => {
|
|
12738
|
+
const {fork} = await __webpack_require__.e(/* import() */ 865).then(__webpack_require__.t.bind(__webpack_require__, 865, 23))
|
|
12739
|
+
this.worker = fork(url, ['easy-worker-child'], options)
|
|
12740
|
+
resolve(this)
|
|
12741
|
+
})
|
|
12742
|
+
}
|
|
12743
|
+
} else {
|
|
12744
|
+
this.#isWorker = true
|
|
12745
|
+
if (globalThis.process?.argv[2] === 'easy-worker-child') {
|
|
12746
|
+
this.worker = process
|
|
12747
|
+
} else {
|
|
12748
|
+
this.#isBrowser = true
|
|
12749
|
+
this.worker = globalThis
|
|
12750
|
+
}
|
|
12751
|
+
}
|
|
12752
|
+
|
|
12753
|
+
return this
|
|
12754
|
+
}
|
|
12755
|
+
|
|
12756
|
+
onmessage(fn) {
|
|
12757
|
+
if (this.#isBrowser) this.worker.onmessage = ({data}) => fn(data)
|
|
12758
|
+
else this.worker.on(this.#messageEvent, fn)
|
|
12759
|
+
}
|
|
12760
|
+
|
|
12761
|
+
postMessage(message) {
|
|
12762
|
+
if (this.#isBrowser) this.worker.postMessage(message);
|
|
12763
|
+
else this.worker.send(message)
|
|
12764
|
+
}
|
|
12765
|
+
|
|
12766
|
+
terminate() {
|
|
12767
|
+
if (this.#isBrowser) this.worker.terminate()
|
|
12768
|
+
else this.worker.kill()
|
|
12769
|
+
}
|
|
12770
|
+
|
|
12771
|
+
onerror(fn) {
|
|
12772
|
+
if (this.#isBrowser) this.worker.onerror = fn
|
|
12773
|
+
else this.worker.on(this.#errorEvent, fn)
|
|
12774
|
+
}
|
|
12775
|
+
|
|
12776
|
+
/**
|
|
12777
|
+
*
|
|
12778
|
+
* @param {*} data
|
|
12779
|
+
* @returns {Promise} resolves result onmessage & rejects on error
|
|
12780
|
+
*/
|
|
12781
|
+
once(data) {
|
|
12782
|
+
return new Promise((resolve, reject) => {
|
|
12783
|
+
this.onmessage(message => {
|
|
12784
|
+
resolve(message)
|
|
12785
|
+
this.terminate()
|
|
12786
|
+
})
|
|
12787
|
+
this.onerror(error => {
|
|
12788
|
+
reject(error)
|
|
12789
|
+
this.terminate()
|
|
12790
|
+
})
|
|
12791
|
+
this.postMessage(data)
|
|
12792
|
+
})
|
|
12793
|
+
}
|
|
12794
|
+
}
|
|
12795
|
+
;// CONCATENATED MODULE: ./dist/module/workers/block-worker.js
|
|
12720
12796
|
|
|
12721
|
-
/**
|
|
12722
|
-
* BigNumber
|
|
12723
|
-
*
|
|
12724
|
-
* A wrapper around the BN.js object. We use the BN.js library
|
|
12725
|
-
* because it is used by elliptic, so it is required regardless.
|
|
12726
|
-
*
|
|
12727
|
-
*/
|
|
12728
12797
|
|
|
12729
|
-
var BN = (bn_default()).BN;
|
|
12730
12798
|
|
|
12731
12799
|
|
|
12732
12800
|
|
|
12733
|
-
|
|
12801
|
+
|
|
12802
|
+
|
|
12803
|
+
var proto = `
|
|
12804
|
+
message ValidatorMessage {
|
|
12805
|
+
required string address = 1;
|
|
12806
|
+
required string reward = 2;
|
|
12807
|
+
}
|
|
12808
|
+
|
|
12809
|
+
message Transaction {
|
|
12810
|
+
required string hash = 1;
|
|
12811
|
+
required uint64 timestamp = 2;
|
|
12812
|
+
required string from = 3;
|
|
12813
|
+
required string to = 4;
|
|
12814
|
+
required uint64 nonce = 5;
|
|
12815
|
+
required string method = 6;
|
|
12816
|
+
repeated string params = 7;
|
|
12817
|
+
}
|
|
12818
|
+
|
|
12819
|
+
message BlockMessage {
|
|
12820
|
+
required uint64 index = 1;
|
|
12821
|
+
required string previousHash = 3;
|
|
12822
|
+
required uint64 timestamp = 4;
|
|
12823
|
+
required uint64 reward = 5;
|
|
12824
|
+
required string fees = 6;
|
|
12825
|
+
repeated Transaction transactions = 7;
|
|
12826
|
+
repeated ValidatorMessage validators = 8;
|
|
12827
|
+
}
|
|
12828
|
+
`;
|
|
12829
|
+
|
|
12830
|
+
class BlockMessage extends src_FormatInterface {
|
|
12831
|
+
get keys() {
|
|
12832
|
+
return ['index', 'previousHash', 'timestamp', 'reward', 'fees', 'transactions', 'validators']
|
|
12833
|
+
}
|
|
12834
|
+
|
|
12835
|
+
get messageName() {
|
|
12836
|
+
return 'BlockMessage'
|
|
12837
|
+
}
|
|
12838
|
+
|
|
12839
|
+
constructor(buffer) {
|
|
12840
|
+
const name = 'block-message';
|
|
12841
|
+
super(buffer, proto, {name});
|
|
12842
|
+
}
|
|
12843
|
+
}
|
|
12844
|
+
|
|
12845
|
+
const version$1 = "bignumber/5.6.2";
|
|
12846
|
+
|
|
12847
|
+
var BN = (bn_default()).BN;
|
|
12848
|
+
const block_worker_logger = new Logger(version$1);
|
|
12734
12849
|
const _constructorGuard = {};
|
|
12735
12850
|
const MAX_SAFE = 0x1fffffffffffff;
|
|
12736
|
-
function isBigNumberish(value) {
|
|
12737
|
-
return (value != null) && (BigNumber.isBigNumber(value) ||
|
|
12738
|
-
(typeof (value) === "number" && (value % 1) === 0) ||
|
|
12739
|
-
(typeof (value) === "string" && !!value.match(/^-?[0-9]+$/)) ||
|
|
12740
|
-
isHexString(value) ||
|
|
12741
|
-
(typeof (value) === "bigint") ||
|
|
12742
|
-
isBytes(value));
|
|
12743
|
-
}
|
|
12744
12851
|
// Only warn about passing 10 into radix once
|
|
12745
12852
|
let _warnedToStringRadix = false;
|
|
12746
12853
|
class BigNumber {
|
|
12747
12854
|
constructor(constructorGuard, hex) {
|
|
12748
12855
|
if (constructorGuard !== _constructorGuard) {
|
|
12749
|
-
|
|
12856
|
+
block_worker_logger.throwError("cannot call constructor directly; use BigNumber.from", Logger.errors.UNSUPPORTED_OPERATION, {
|
|
12750
12857
|
operation: "new (BigNumber)"
|
|
12751
12858
|
});
|
|
12752
12859
|
}
|
|
@@ -12870,7 +12977,7 @@ class BigNumber {
|
|
|
12870
12977
|
return BigInt(this.toString());
|
|
12871
12978
|
}
|
|
12872
12979
|
catch (e) { }
|
|
12873
|
-
return
|
|
12980
|
+
return block_worker_logger.throwError("this platform does not support BigInt", Logger.errors.UNSUPPORTED_OPERATION, {
|
|
12874
12981
|
value: this.toString()
|
|
12875
12982
|
});
|
|
12876
12983
|
}
|
|
@@ -12880,14 +12987,14 @@ class BigNumber {
|
|
|
12880
12987
|
if (arguments[0] === 10) {
|
|
12881
12988
|
if (!_warnedToStringRadix) {
|
|
12882
12989
|
_warnedToStringRadix = true;
|
|
12883
|
-
|
|
12990
|
+
block_worker_logger.warn("BigNumber.toString does not accept any parameters; base-10 is assumed");
|
|
12884
12991
|
}
|
|
12885
12992
|
}
|
|
12886
12993
|
else if (arguments[0] === 16) {
|
|
12887
|
-
|
|
12994
|
+
block_worker_logger.throwError("BigNumber.toString does not accept any parameters; use bigNumber.toHexString()", Logger.errors.UNEXPECTED_ARGUMENT, {});
|
|
12888
12995
|
}
|
|
12889
12996
|
else {
|
|
12890
|
-
|
|
12997
|
+
block_worker_logger.throwError("BigNumber.toString does not accept parameters", Logger.errors.UNEXPECTED_ARGUMENT, {});
|
|
12891
12998
|
}
|
|
12892
12999
|
}
|
|
12893
13000
|
return toBN(this).toString(10);
|
|
@@ -12909,7 +13016,7 @@ class BigNumber {
|
|
|
12909
13016
|
if (value.match(/^-?[0-9]+$/)) {
|
|
12910
13017
|
return new BigNumber(_constructorGuard, toHex(new BN(value)));
|
|
12911
13018
|
}
|
|
12912
|
-
return
|
|
13019
|
+
return block_worker_logger.throwArgumentError("invalid BigNumber string", "value", value);
|
|
12913
13020
|
}
|
|
12914
13021
|
if (typeof (value) === "number") {
|
|
12915
13022
|
if (value % 1) {
|
|
@@ -12924,7 +13031,7 @@ class BigNumber {
|
|
|
12924
13031
|
if (typeof (anyValue) === "bigint") {
|
|
12925
13032
|
return BigNumber.from(anyValue.toString());
|
|
12926
13033
|
}
|
|
12927
|
-
if (
|
|
13034
|
+
if (isBytes(anyValue)) {
|
|
12928
13035
|
return BigNumber.from(hexlify(anyValue));
|
|
12929
13036
|
}
|
|
12930
13037
|
if (anyValue) {
|
|
@@ -12943,13 +13050,13 @@ class BigNumber {
|
|
|
12943
13050
|
hex = anyValue.hex;
|
|
12944
13051
|
}
|
|
12945
13052
|
if (typeof (hex) === "string") {
|
|
12946
|
-
if (
|
|
13053
|
+
if (isHexString(hex) || (hex[0] === "-" && isHexString(hex.substring(1)))) {
|
|
12947
13054
|
return BigNumber.from(hex);
|
|
12948
13055
|
}
|
|
12949
13056
|
}
|
|
12950
13057
|
}
|
|
12951
13058
|
}
|
|
12952
|
-
return
|
|
13059
|
+
return block_worker_logger.throwArgumentError("invalid BigNumber value", "value", value);
|
|
12953
13060
|
}
|
|
12954
13061
|
static isBigNumber(value) {
|
|
12955
13062
|
return !!(value && value._isBigNumber);
|
|
@@ -12967,7 +13074,7 @@ function toHex(value) {
|
|
|
12967
13074
|
value = value.substring(1);
|
|
12968
13075
|
// Cannot have multiple negative signs (e.g. "--0x04")
|
|
12969
13076
|
if (value[0] === "-") {
|
|
12970
|
-
|
|
13077
|
+
block_worker_logger.throwArgumentError("invalid hex", "value", value);
|
|
12971
13078
|
}
|
|
12972
13079
|
// Call toHex on the positive component
|
|
12973
13080
|
value = toHex(value);
|
|
@@ -13011,143 +13118,12 @@ function throwFault(fault, operation, value) {
|
|
|
13011
13118
|
if (value != null) {
|
|
13012
13119
|
params.value = value;
|
|
13013
13120
|
}
|
|
13014
|
-
return
|
|
13015
|
-
}
|
|
13016
|
-
// value should have no prefix
|
|
13017
|
-
function _base36To16(value) {
|
|
13018
|
-
return (new BN(value, 36)).toString(16);
|
|
13019
|
-
}
|
|
13020
|
-
// value should have no prefix
|
|
13021
|
-
function _base16To36(value) {
|
|
13022
|
-
return (new BN(value, 16)).toString(36);
|
|
13121
|
+
return block_worker_logger.throwError(fault, Logger.errors.NUMERIC_FAULT, params);
|
|
13023
13122
|
}
|
|
13024
|
-
//# sourceMappingURL=bignumber.js.map
|
|
13025
|
-
;// CONCATENATED MODULE: ./node_modules/@vandeurenglenn/easy-worker/src/worker.js
|
|
13026
|
-
/* provided dependency */ var process = __webpack_require__(155);
|
|
13027
|
-
class EasyWorker {
|
|
13028
|
-
#messageEvent = 'message'
|
|
13029
|
-
#errorEvent = 'error'
|
|
13030
|
-
#isBrowser = false
|
|
13031
|
-
#isWorker = false
|
|
13032
|
-
|
|
13033
|
-
get isWorker() {
|
|
13034
|
-
return this.#isWorker
|
|
13035
|
-
}
|
|
13036
|
-
constructor(url, options) {
|
|
13037
|
-
return this.#init(url, options)
|
|
13038
|
-
}
|
|
13039
|
-
|
|
13040
|
-
#init(url, options = {}) {
|
|
13041
|
-
if (url) {
|
|
13042
|
-
if (globalThis.Worker) {
|
|
13043
|
-
this.#isBrowser = true
|
|
13044
|
-
this.worker = new Worker(url, {...options})
|
|
13045
|
-
} else {
|
|
13046
|
-
return new Promise(async (resolve, reject) => {
|
|
13047
|
-
const {fork} = await __webpack_require__.e(/* import() */ 865).then(__webpack_require__.t.bind(__webpack_require__, 865, 23))
|
|
13048
|
-
this.worker = fork(url, ['easy-worker-child'], options)
|
|
13049
|
-
resolve(this)
|
|
13050
|
-
})
|
|
13051
|
-
}
|
|
13052
|
-
} else {
|
|
13053
|
-
this.#isWorker = true
|
|
13054
|
-
if (globalThis.process?.argv[2] === 'easy-worker-child') {
|
|
13055
|
-
this.worker = process
|
|
13056
|
-
} else {
|
|
13057
|
-
this.#isBrowser = true
|
|
13058
|
-
this.worker = globalThis
|
|
13059
|
-
}
|
|
13060
|
-
}
|
|
13061
|
-
|
|
13062
|
-
return this
|
|
13063
|
-
}
|
|
13064
|
-
|
|
13065
|
-
onmessage(fn) {
|
|
13066
|
-
if (this.#isBrowser) this.worker.onmessage = ({data}) => fn(data)
|
|
13067
|
-
else this.worker.on(this.#messageEvent, fn)
|
|
13068
|
-
}
|
|
13069
|
-
|
|
13070
|
-
postMessage(message) {
|
|
13071
|
-
if (this.#isBrowser) this.worker.postMessage(message);
|
|
13072
|
-
else this.worker.send(message)
|
|
13073
|
-
}
|
|
13074
|
-
|
|
13075
|
-
terminate() {
|
|
13076
|
-
if (this.#isBrowser) this.worker.terminate()
|
|
13077
|
-
else this.worker.kill()
|
|
13078
|
-
}
|
|
13079
|
-
|
|
13080
|
-
onerror(fn) {
|
|
13081
|
-
if (this.#isBrowser) this.worker.onerror = fn
|
|
13082
|
-
else this.worker.on(this.#errorEvent, fn)
|
|
13083
|
-
}
|
|
13084
|
-
|
|
13085
|
-
/**
|
|
13086
|
-
*
|
|
13087
|
-
* @param {*} data
|
|
13088
|
-
* @returns {Promise} resolves result onmessage & rejects on error
|
|
13089
|
-
*/
|
|
13090
|
-
once(data) {
|
|
13091
|
-
return new Promise((resolve, reject) => {
|
|
13092
|
-
this.onmessage(message => {
|
|
13093
|
-
resolve(message)
|
|
13094
|
-
this.terminate()
|
|
13095
|
-
})
|
|
13096
|
-
this.onerror(error => {
|
|
13097
|
-
reject(error)
|
|
13098
|
-
this.terminate()
|
|
13099
|
-
})
|
|
13100
|
-
this.postMessage(data)
|
|
13101
|
-
})
|
|
13102
|
-
}
|
|
13103
|
-
}
|
|
13104
|
-
;// CONCATENATED MODULE: ./dist/module/workers/block-worker.js
|
|
13105
|
-
|
|
13106
|
-
|
|
13107
|
-
|
|
13108
|
-
|
|
13109
13123
|
|
|
13110
|
-
|
|
13111
|
-
message ValidatorMessage {
|
|
13112
|
-
required string address = 1;
|
|
13113
|
-
required string reward = 2;
|
|
13114
|
-
}
|
|
13115
|
-
|
|
13116
|
-
message Transaction {
|
|
13117
|
-
required string hash = 1;
|
|
13118
|
-
required uint64 timestamp = 2;
|
|
13119
|
-
required string from = 3;
|
|
13120
|
-
required string to = 4;
|
|
13121
|
-
required uint64 nonce = 5;
|
|
13122
|
-
required string method = 6;
|
|
13123
|
-
repeated string params = 7;
|
|
13124
|
-
}
|
|
13125
|
-
|
|
13126
|
-
message BlockMessage {
|
|
13127
|
-
required uint64 index = 1;
|
|
13128
|
-
required string previousHash = 3;
|
|
13129
|
-
required uint64 timestamp = 4;
|
|
13130
|
-
required uint64 reward = 5;
|
|
13131
|
-
required string fees = 6;
|
|
13132
|
-
repeated Transaction transactions = 7;
|
|
13133
|
-
repeated ValidatorMessage validators = 8;
|
|
13134
|
-
}
|
|
13135
|
-
`;
|
|
13124
|
+
const block_worker_version = "units/5.6.1";
|
|
13136
13125
|
|
|
13137
|
-
|
|
13138
|
-
get keys() {
|
|
13139
|
-
return ['index', 'previousHash', 'timestamp', 'reward', 'fees', 'transactions', 'validators']
|
|
13140
|
-
}
|
|
13141
|
-
|
|
13142
|
-
get messageName() {
|
|
13143
|
-
return 'BlockMessage'
|
|
13144
|
-
}
|
|
13145
|
-
|
|
13146
|
-
constructor(buffer) {
|
|
13147
|
-
const name = 'block-message';
|
|
13148
|
-
super(buffer, proto, {name});
|
|
13149
|
-
}
|
|
13150
|
-
}
|
|
13126
|
+
new Logger(block_worker_version);
|
|
13151
13127
|
|
|
13152
13128
|
const byteFormats = ['Bytes', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];
|
|
13153
13129
|
|