@leofcoin/workers 1.3.8 → 1.3.10

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.
Files changed (51) hide show
  1. package/package.json +5 -3
  2. package/src/block-worker.js +1 -10
  3. package/src/machine-worker.js +21 -18
  4. package/src/pool-worker.js +0 -9
  5. package/src/transaction-worker.js +1 -9
  6. package/dist/bundle/commonjs/block-worker-21ad8152.js +0 -45
  7. package/dist/bundle/commonjs/block-worker.js +0 -14
  8. package/dist/bundle/commonjs/machine-worker-70f71351.js +0 -255
  9. package/dist/bundle/commonjs/machine-worker.js +0 -14
  10. package/dist/bundle/commonjs/pool-worker-f450eeff.js +0 -35
  11. package/dist/bundle/commonjs/pool-worker.js +0 -14
  12. package/dist/bundle/commonjs/transaction-d7c6a8ee.js +0 -33
  13. package/dist/bundle/commonjs/transaction-worker-176a5aaa.js +0 -27
  14. package/dist/bundle/commonjs/transaction-worker.js +0 -14
  15. package/dist/bundle/commonjs/utils-6e881be4.js +0 -4139
  16. package/dist/bundle/commonjs/worker-6ace445f.js +0 -4891
  17. package/dist/bundle/commonjs/workers.js +0 -29
  18. package/dist/bundle/module/block-worker-414860e0.js +0 -43
  19. package/dist/bundle/module/block-worker.js +0 -11
  20. package/dist/bundle/module/machine-worker-5896ac08.js +0 -253
  21. package/dist/bundle/module/machine-worker.js +0 -11
  22. package/dist/bundle/module/pool-worker-0d927e3c.js +0 -33
  23. package/dist/bundle/module/pool-worker.js +0 -11
  24. package/dist/bundle/module/transaction-cec98ce8.js +0 -31
  25. package/dist/bundle/module/transaction-worker-548cd200.js +0 -25
  26. package/dist/bundle/module/transaction-worker.js +0 -11
  27. package/dist/bundle/module/utils-ac8c68e6.js +0 -4135
  28. package/dist/bundle/module/worker-def77c26.js +0 -4858
  29. package/dist/bundle/module/workers.js +0 -22
  30. package/dist/commonjs/block-worker-60e4cfa3.js +0 -50
  31. package/dist/commonjs/block-worker.js +0 -11
  32. package/dist/commonjs/machine-worker-b46cac38.js +0 -260
  33. package/dist/commonjs/machine-worker.js +0 -11
  34. package/dist/commonjs/pool-worker-81e8b4c0.js +0 -40
  35. package/dist/commonjs/pool-worker.js +0 -7
  36. package/dist/commonjs/transaction-220a3a15.js +0 -33
  37. package/dist/commonjs/transaction-worker-8eecc7a1.js +0 -32
  38. package/dist/commonjs/transaction-worker.js +0 -7
  39. package/dist/commonjs/utils-1dc37f72.js +0 -352
  40. package/dist/commonjs/workers.js +0 -26
  41. package/dist/module/block-worker-f539b1b2.js +0 -44
  42. package/dist/module/block-worker.js +0 -8
  43. package/dist/module/machine-worker-da95e492.js +0 -254
  44. package/dist/module/machine-worker.js +0 -8
  45. package/dist/module/pool-worker-f65671d7.js +0 -34
  46. package/dist/module/pool-worker.js +0 -4
  47. package/dist/module/transaction-d06dc6c4.js +0 -31
  48. package/dist/module/transaction-worker-105deaa8.js +0 -26
  49. package/dist/module/transaction-worker.js +0 -4
  50. package/dist/module/utils-e87bc63d.js +0 -344
  51. package/dist/module/workers.js +0 -19
@@ -1,352 +0,0 @@
1
- 'use strict';
2
-
3
- var codecFormatInterface = require('@leofcoin/codec-format-interface');
4
- var _BN = require('bn.js');
5
- var bytes = require('@ethersproject/bytes');
6
- var logger$1 = require('@ethersproject/logger');
7
- require('@ethersproject/bignumber');
8
-
9
- function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
10
-
11
- var _BN__default = /*#__PURE__*/_interopDefaultLegacy(_BN);
12
-
13
- var proto = `
14
- message ValidatorMessage {
15
- required string address = 1;
16
- required string reward = 2;
17
- }
18
-
19
- message Transaction {
20
- required string hash = 1;
21
- required uint64 timestamp = 2;
22
- required string from = 3;
23
- required string to = 4;
24
- required uint64 nonce = 5;
25
- required string method = 6;
26
- repeated string params = 7;
27
- }
28
-
29
- message BlockMessage {
30
- required uint64 index = 1;
31
- required string previousHash = 3;
32
- required uint64 timestamp = 4;
33
- required uint64 reward = 5;
34
- required string fees = 6;
35
- repeated Transaction transactions = 7;
36
- repeated ValidatorMessage validators = 8;
37
- }
38
- `;
39
-
40
- class BlockMessage extends codecFormatInterface.FormatInterface {
41
- get keys() {
42
- return ['index', 'previousHash', 'timestamp', 'reward', 'fees', 'transactions', 'validators']
43
- }
44
-
45
- get messageName() {
46
- return 'BlockMessage'
47
- }
48
-
49
- constructor(buffer) {
50
- const name = 'block-message';
51
- super(buffer, proto, {name});
52
- }
53
- }
54
-
55
- const version$1 = "bignumber/5.6.2";
56
-
57
- var BN = _BN__default["default"].BN;
58
- const logger = new logger$1.Logger(version$1);
59
- const _constructorGuard = {};
60
- const MAX_SAFE = 0x1fffffffffffff;
61
- // Only warn about passing 10 into radix once
62
- let _warnedToStringRadix = false;
63
- class BigNumber {
64
- constructor(constructorGuard, hex) {
65
- if (constructorGuard !== _constructorGuard) {
66
- logger.throwError("cannot call constructor directly; use BigNumber.from", logger$1.Logger.errors.UNSUPPORTED_OPERATION, {
67
- operation: "new (BigNumber)"
68
- });
69
- }
70
- this._hex = hex;
71
- this._isBigNumber = true;
72
- Object.freeze(this);
73
- }
74
- fromTwos(value) {
75
- return toBigNumber(toBN(this).fromTwos(value));
76
- }
77
- toTwos(value) {
78
- return toBigNumber(toBN(this).toTwos(value));
79
- }
80
- abs() {
81
- if (this._hex[0] === "-") {
82
- return BigNumber.from(this._hex.substring(1));
83
- }
84
- return this;
85
- }
86
- add(other) {
87
- return toBigNumber(toBN(this).add(toBN(other)));
88
- }
89
- sub(other) {
90
- return toBigNumber(toBN(this).sub(toBN(other)));
91
- }
92
- div(other) {
93
- const o = BigNumber.from(other);
94
- if (o.isZero()) {
95
- throwFault("division-by-zero", "div");
96
- }
97
- return toBigNumber(toBN(this).div(toBN(other)));
98
- }
99
- mul(other) {
100
- return toBigNumber(toBN(this).mul(toBN(other)));
101
- }
102
- mod(other) {
103
- const value = toBN(other);
104
- if (value.isNeg()) {
105
- throwFault("division-by-zero", "mod");
106
- }
107
- return toBigNumber(toBN(this).umod(value));
108
- }
109
- pow(other) {
110
- const value = toBN(other);
111
- if (value.isNeg()) {
112
- throwFault("negative-power", "pow");
113
- }
114
- return toBigNumber(toBN(this).pow(value));
115
- }
116
- and(other) {
117
- const value = toBN(other);
118
- if (this.isNegative() || value.isNeg()) {
119
- throwFault("unbound-bitwise-result", "and");
120
- }
121
- return toBigNumber(toBN(this).and(value));
122
- }
123
- or(other) {
124
- const value = toBN(other);
125
- if (this.isNegative() || value.isNeg()) {
126
- throwFault("unbound-bitwise-result", "or");
127
- }
128
- return toBigNumber(toBN(this).or(value));
129
- }
130
- xor(other) {
131
- const value = toBN(other);
132
- if (this.isNegative() || value.isNeg()) {
133
- throwFault("unbound-bitwise-result", "xor");
134
- }
135
- return toBigNumber(toBN(this).xor(value));
136
- }
137
- mask(value) {
138
- if (this.isNegative() || value < 0) {
139
- throwFault("negative-width", "mask");
140
- }
141
- return toBigNumber(toBN(this).maskn(value));
142
- }
143
- shl(value) {
144
- if (this.isNegative() || value < 0) {
145
- throwFault("negative-width", "shl");
146
- }
147
- return toBigNumber(toBN(this).shln(value));
148
- }
149
- shr(value) {
150
- if (this.isNegative() || value < 0) {
151
- throwFault("negative-width", "shr");
152
- }
153
- return toBigNumber(toBN(this).shrn(value));
154
- }
155
- eq(other) {
156
- return toBN(this).eq(toBN(other));
157
- }
158
- lt(other) {
159
- return toBN(this).lt(toBN(other));
160
- }
161
- lte(other) {
162
- return toBN(this).lte(toBN(other));
163
- }
164
- gt(other) {
165
- return toBN(this).gt(toBN(other));
166
- }
167
- gte(other) {
168
- return toBN(this).gte(toBN(other));
169
- }
170
- isNegative() {
171
- return (this._hex[0] === "-");
172
- }
173
- isZero() {
174
- return toBN(this).isZero();
175
- }
176
- toNumber() {
177
- try {
178
- return toBN(this).toNumber();
179
- }
180
- catch (error) {
181
- throwFault("overflow", "toNumber", this.toString());
182
- }
183
- return null;
184
- }
185
- toBigInt() {
186
- try {
187
- return BigInt(this.toString());
188
- }
189
- catch (e) { }
190
- return logger.throwError("this platform does not support BigInt", logger$1.Logger.errors.UNSUPPORTED_OPERATION, {
191
- value: this.toString()
192
- });
193
- }
194
- toString() {
195
- // Lots of people expect this, which we do not support, so check (See: #889)
196
- if (arguments.length > 0) {
197
- if (arguments[0] === 10) {
198
- if (!_warnedToStringRadix) {
199
- _warnedToStringRadix = true;
200
- logger.warn("BigNumber.toString does not accept any parameters; base-10 is assumed");
201
- }
202
- }
203
- else if (arguments[0] === 16) {
204
- logger.throwError("BigNumber.toString does not accept any parameters; use bigNumber.toHexString()", logger$1.Logger.errors.UNEXPECTED_ARGUMENT, {});
205
- }
206
- else {
207
- logger.throwError("BigNumber.toString does not accept parameters", logger$1.Logger.errors.UNEXPECTED_ARGUMENT, {});
208
- }
209
- }
210
- return toBN(this).toString(10);
211
- }
212
- toHexString() {
213
- return this._hex;
214
- }
215
- toJSON(key) {
216
- return { type: "BigNumber", hex: this.toHexString() };
217
- }
218
- static from(value) {
219
- if (value instanceof BigNumber) {
220
- return value;
221
- }
222
- if (typeof (value) === "string") {
223
- if (value.match(/^-?0x[0-9a-f]+$/i)) {
224
- return new BigNumber(_constructorGuard, toHex(value));
225
- }
226
- if (value.match(/^-?[0-9]+$/)) {
227
- return new BigNumber(_constructorGuard, toHex(new BN(value)));
228
- }
229
- return logger.throwArgumentError("invalid BigNumber string", "value", value);
230
- }
231
- if (typeof (value) === "number") {
232
- if (value % 1) {
233
- throwFault("underflow", "BigNumber.from", value);
234
- }
235
- if (value >= MAX_SAFE || value <= -MAX_SAFE) {
236
- throwFault("overflow", "BigNumber.from", value);
237
- }
238
- return BigNumber.from(String(value));
239
- }
240
- const anyValue = value;
241
- if (typeof (anyValue) === "bigint") {
242
- return BigNumber.from(anyValue.toString());
243
- }
244
- if (bytes.isBytes(anyValue)) {
245
- return BigNumber.from(bytes.hexlify(anyValue));
246
- }
247
- if (anyValue) {
248
- // Hexable interface (takes priority)
249
- if (anyValue.toHexString) {
250
- const hex = anyValue.toHexString();
251
- if (typeof (hex) === "string") {
252
- return BigNumber.from(hex);
253
- }
254
- }
255
- else {
256
- // For now, handle legacy JSON-ified values (goes away in v6)
257
- let hex = anyValue._hex;
258
- // New-form JSON
259
- if (hex == null && anyValue.type === "BigNumber") {
260
- hex = anyValue.hex;
261
- }
262
- if (typeof (hex) === "string") {
263
- if (bytes.isHexString(hex) || (hex[0] === "-" && bytes.isHexString(hex.substring(1)))) {
264
- return BigNumber.from(hex);
265
- }
266
- }
267
- }
268
- }
269
- return logger.throwArgumentError("invalid BigNumber value", "value", value);
270
- }
271
- static isBigNumber(value) {
272
- return !!(value && value._isBigNumber);
273
- }
274
- }
275
- // Normalize the hex string
276
- function toHex(value) {
277
- // For BN, call on the hex string
278
- if (typeof (value) !== "string") {
279
- return toHex(value.toString(16));
280
- }
281
- // If negative, prepend the negative sign to the normalized positive value
282
- if (value[0] === "-") {
283
- // Strip off the negative sign
284
- value = value.substring(1);
285
- // Cannot have multiple negative signs (e.g. "--0x04")
286
- if (value[0] === "-") {
287
- logger.throwArgumentError("invalid hex", "value", value);
288
- }
289
- // Call toHex on the positive component
290
- value = toHex(value);
291
- // Do not allow "-0x00"
292
- if (value === "0x00") {
293
- return value;
294
- }
295
- // Negate the value
296
- return "-" + value;
297
- }
298
- // Add a "0x" prefix if missing
299
- if (value.substring(0, 2) !== "0x") {
300
- value = "0x" + value;
301
- }
302
- // Normalize zero
303
- if (value === "0x") {
304
- return "0x00";
305
- }
306
- // Make the string even length
307
- if (value.length % 2) {
308
- value = "0x0" + value.substring(2);
309
- }
310
- // Trim to smallest even-length string
311
- while (value.length > 4 && value.substring(0, 4) === "0x00") {
312
- value = "0x" + value.substring(4);
313
- }
314
- return value;
315
- }
316
- function toBigNumber(value) {
317
- return BigNumber.from(toHex(value));
318
- }
319
- function toBN(value) {
320
- const hex = BigNumber.from(value).toHexString();
321
- if (hex[0] === "-") {
322
- return (new BN("-" + hex.substring(3), 16));
323
- }
324
- return new BN(hex.substring(2), 16);
325
- }
326
- function throwFault(fault, operation, value) {
327
- const params = { fault: fault, operation: operation };
328
- if (value != null) {
329
- params.value = value;
330
- }
331
- return logger.throwError(fault, logger$1.Logger.errors.NUMERIC_FAULT, params);
332
- }
333
-
334
- const version = "units/5.6.1";
335
-
336
- new logger$1.Logger(version);
337
-
338
- const byteFormats = ['Bytes', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];
339
-
340
- const formatBytes = (bytes, decimals = 2) => {
341
- if (bytes === 0) return '0 Bytes';
342
- if (decimals < 0) decimals = 0;
343
-
344
- const k = 1024;
345
- const i = Math.floor(Math.log(bytes) / Math.log(k));
346
-
347
- return `${parseFloat((bytes / Math.pow(k, i)).toFixed(decimals))} ${byteFormats[i]}`
348
- };
349
-
350
- exports.BigNumber = BigNumber;
351
- exports.BlockMessage = BlockMessage;
352
- exports.formatBytes = formatBytes;
@@ -1,26 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- var transactionWorker = require('./transaction-worker-8eecc7a1.js');
6
- var blockWorker = require('./block-worker-60e4cfa3.js');
7
- var poolWorker = require('./pool-worker-81e8b4c0.js');
8
- var machineWorker = require('./machine-worker-b46cac38.js');
9
- require('@leofcoin/codec-format-interface');
10
- require('./transaction-220a3a15.js');
11
- require('@vandeurenglenn/easy-worker');
12
- require('./utils-1dc37f72.js');
13
- require('bn.js');
14
- require('@ethersproject/bytes');
15
- require('@ethersproject/logger');
16
- require('@ethersproject/bignumber');
17
-
18
- const TransactionWorker = transactionWorker.transactionWorker;
19
- const BlockWorker = blockWorker.blockWorker;
20
- const PoolWorker = poolWorker.poolWorker;
21
- const MachineWorker = machineWorker.machineWorker;
22
-
23
- exports.BlockWorker = BlockWorker;
24
- exports.MachineWorker = MachineWorker;
25
- exports.PoolWorker = PoolWorker;
26
- exports.TransactionWorker = TransactionWorker;
@@ -1,44 +0,0 @@
1
- import '@leofcoin/codec-format-interface';
2
- import { B as BigNumber, a as BlockMessage, f as formatBytes } from './utils-e87bc63d.js';
3
- import EasyWorker from '@vandeurenglenn/easy-worker';
4
-
5
- const worker = new EasyWorker();
6
-
7
- globalThis.BigNumber = BigNumber;
8
-
9
- globalThis.peernet = globalThis.peernet || {};
10
- globalThis.contracts = {};
11
-
12
- const run = async (blocks) => {
13
- blocks = await Promise.all(blocks.map(block => new BlockMessage(block)));
14
- blocks = blocks.sort((a, b) => a.decoded.timestamp - b.decoded.timestamp);
15
-
16
- blocks = await Promise.all(blocks.map(block => new Promise(async (resolve, reject) => {
17
- // todo: tx worker or nah?
18
- const size = block.encoded.length || block.encoded.byteLength;
19
- console.log(`loaded block: ${await block.hash} @${block.decoded.index} ${formatBytes(size)}`);
20
- resolve(block);
21
- })));
22
- return blocks
23
- };
24
-
25
- const tasks = async blocks => {
26
- globalThis.peernet.codecs = {
27
- 'block-message': {
28
- codec: parseInt('626d', 16),
29
- hashAlg: 'keccak-256'
30
- }
31
- };
32
-
33
- blocks = await run(blocks);
34
- worker.postMessage(blocks);
35
- };
36
-
37
-
38
- worker.onmessage(data => tasks(data));
39
-
40
- var blockWorker = /*#__PURE__*/Object.freeze({
41
- __proto__: null
42
- });
43
-
44
- export { blockWorker as b };
@@ -1,8 +0,0 @@
1
- import '@leofcoin/codec-format-interface';
2
- import './utils-e87bc63d.js';
3
- import '@vandeurenglenn/easy-worker';
4
- import './block-worker-f539b1b2.js';
5
- import 'bn.js';
6
- import '@ethersproject/bytes';
7
- import '@ethersproject/logger';
8
- import '@ethersproject/bignumber';