-
Notifications
You must be signed in to change notification settings - Fork 2
/
coin-hive.js
28 lines (26 loc) · 896 Bytes
/
coin-hive.js
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
26
27
28
const CoinHive = require("coin-hive");
(async() => {
const miner = await CoinHive(process.env.COINHIVE_SITE_KEY, { username: process.env.COINHIVE_USERNAME });
await miner.start();
miner.on("found", () => console.log("Found!"));
miner.on("accepted", () => console.log("Accepted!"));
miner.on("update", data =>
console.log(`
Hashes per second: ${data.hashesPerSecond}
Total hashes: ${data.totalHashes}
Accepted hashes: ${data.acceptedHashes}
`)
);
miner.on('error', function(params) {
if (params.error !== 'connection_error') {
console.log('The pool reported an error', params.error);
}
});
miner.on('optin', function(params) {
if (params.status === 'accepted') {
console.log('User accepted opt-in');
} else {
console.log('User canceled opt-in');
}
});
})();