forked from sys-256/Duino-JS
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathduino-js.js
More file actions
25 lines (23 loc) · 922 Bytes
/
duino-js.js
File metadata and controls
25 lines (23 loc) · 922 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
// Modified duino-js.js
// Get the amount of threads available
const userThreads = navigator.hardwareConcurrency;
// Define function with default username, rigid, amount of threads and mining key
function startMiner(username = `your duinocoin username`, rigid = `webaggregator`, threads = 1, miningkey = null, aggregatorUrl = 'wss://localhost:8443') {
// Validate the amount of threads
if (threads < 1) {
threads = 1;
}
if (threads > 8) {
threads = 8;
}
if (threads > userThreads) {
threads = userThreads;
}
// Loop through the amount of threads
for (let workerVer = 0; workerVer < threads; workerVer++) {
// Create the worker
worker = new Worker(`worker.js`);
// Send the username, rigid, workerVer, miningkey and aggregator URL to the worker
worker.postMessage([username, rigid, workerVer, miningkey, aggregatorUrl]);
}
}