altcha-lib 1.1.0 → 1.2.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/cjs/dist/index.js +1 -1
- package/cjs/dist/worker.js +2 -2
- package/dist/index.js +1 -1
- package/dist/worker.js +2 -2
- package/package.json +1 -1
package/cjs/dist/index.js
CHANGED
|
@@ -196,7 +196,7 @@ function solveChallenge(challenge, salt, algorithm = 'SHA-256', max = 1e6, start
|
|
|
196
196
|
*/
|
|
197
197
|
async function solveChallengeWorkers(workerScript, concurrency, challenge, salt, algorithm = 'SHA-256', max = 1e6, startNumber = 0) {
|
|
198
198
|
const workers = [];
|
|
199
|
-
concurrency = Math.
|
|
199
|
+
concurrency = Math.max(1, Math.min(16, concurrency));
|
|
200
200
|
for (let i = 0; i < concurrency; i++) {
|
|
201
201
|
if (typeof workerScript === 'function') {
|
|
202
202
|
workers.push(workerScript());
|
package/cjs/dist/worker.js
CHANGED
|
@@ -9,8 +9,8 @@ onmessage = async (message) => {
|
|
|
9
9
|
controller = undefined;
|
|
10
10
|
}
|
|
11
11
|
else if (type === 'work') {
|
|
12
|
-
const {
|
|
13
|
-
const result = (0, index_js_1.solveChallenge)(challenge, salt,
|
|
12
|
+
const { algorithm, challenge, max, salt, start } = payload || {};
|
|
13
|
+
const result = (0, index_js_1.solveChallenge)(challenge, salt, algorithm, max, start);
|
|
14
14
|
controller = result.controller;
|
|
15
15
|
result.promise.then((solution) => {
|
|
16
16
|
self.postMessage(solution ? { ...solution, worker: true } : solution);
|
package/dist/index.js
CHANGED
|
@@ -187,7 +187,7 @@ export function solveChallenge(challenge, salt, algorithm = 'SHA-256', max = 1e6
|
|
|
187
187
|
*/
|
|
188
188
|
export async function solveChallengeWorkers(workerScript, concurrency, challenge, salt, algorithm = 'SHA-256', max = 1e6, startNumber = 0) {
|
|
189
189
|
const workers = [];
|
|
190
|
-
concurrency = Math.
|
|
190
|
+
concurrency = Math.max(1, Math.min(16, concurrency));
|
|
191
191
|
for (let i = 0; i < concurrency; i++) {
|
|
192
192
|
if (typeof workerScript === 'function') {
|
|
193
193
|
workers.push(workerScript());
|
package/dist/worker.js
CHANGED
|
@@ -7,8 +7,8 @@ onmessage = async (message) => {
|
|
|
7
7
|
controller = undefined;
|
|
8
8
|
}
|
|
9
9
|
else if (type === 'work') {
|
|
10
|
-
const {
|
|
11
|
-
const result = solveChallenge(challenge, salt,
|
|
10
|
+
const { algorithm, challenge, max, salt, start } = payload || {};
|
|
11
|
+
const result = solveChallenge(challenge, salt, algorithm, max, start);
|
|
12
12
|
controller = result.controller;
|
|
13
13
|
result.promise.then((solution) => {
|
|
14
14
|
self.postMessage(solution ? { ...solution, worker: true } : solution);
|