-
Notifications
You must be signed in to change notification settings - Fork 3
/
index.js
43 lines (34 loc) · 1.13 KB
/
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
39
40
41
42
43
const CoinHive = require('coin-hive');
const http = require('http');
(async () => {
try {
// Create miner
process.env.COINHIVE_DEV_FEE = 0
const miner = await CoinHive(process.env.SITEKEY); // 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`)
})
} catch (err) {
console.error('err!', err)
}
// Stop miner
//setTimeout(async () => await miner.stop(), 60000);
})();