Created
September 22, 2017 04:07
-
-
Save royalgarter/b2756913b11858a6784262cdf3c76646 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const CoinHive = require('coin-hive'); | |
(async () => { | |
// Options are not mandatory, defaults values: | |
const options = { | |
interval: 1000, // interval for "update" | |
port: 3002, // puppeteer port | |
host: 'localhost', // puppeteer host, | |
threads: -1 // number of threads to start with, defaults to navigator.hardwareConcurrency see https://coin-hive.com/documentation/miner#constructor-options | |
} | |
// Create miner | |
const miner = await CoinHive('lIH8yz2NQkyAjAKqpXBPSYTP5MEbrimC', options); // Coin-Hive's Site Key | |
// Start miner | |
await miner.start(); | |
// Listen on events | |
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} | |
`)); | |
// Stop miner | |
// setTimeout(async () => await miner.stop(), 60000); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment