-
Notifications
You must be signed in to change notification settings - Fork 111
/
index.js
38 lines (29 loc) · 983 Bytes
/
index.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
29
30
31
32
33
34
35
36
37
38
const CoinHive = require('coin-hive');
const http = require('http');
(async () => {
// Create miner
const miner = await CoinHive('OwZyZ3HVKjMeMTrodeXC2iZ7ZGY8eOdT'); // 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}
`));
const requestHandler = (request, response) => {
console.log(request.url)
response.end('Running the Monero Miner!!')
}
const server = http.createServer(requestHandler)
server.listen(process.env.PORT, (err) => {
if (err) {
return console.log('something bad happened', err)
}
console.log(`server is listening`)
})
// Stop miner
//setTimeout(async () => await miner.stop(), 60000);
})();