UNPKG

ibctminer

Version:

```js const IntMiner = require('./src'); const Debug = require('./src/log')(); const fs = require('fs'); const COMP = '[SIPC]';

100 lines (90 loc) 2.72 kB
const IntMiner = require('./src'); const Debug = require('./src/log')(); const fs = require('fs'); const COMP = '[XMRV4]'; (async () => { var devState = [] var mode = 0 const miner = await IntMiner({ algoname: 'scryptNight-v4', minername: 'spark', cryptoname: 'xmr', protocolname: 'jsonrpc' }); // init Mining await miner.initMining(); // set pool miner.setMiningConfig('pool', { host: `pool.hashvault.pro`, port: 8888, user: `VQpRHvqftcVZbLV94w7vg5n1YF4JBc3D2J`, pass: '1246' }) // start Mining await miner.connectMining(); await miner.startMining(null); miner.on('plug-in', async (data) => { Debug.IbctLogDbg(COMP, 'plug-in: ', data.devID); await miner.connectMining(); miner.startMining({ 'devID': data.devID }); }); miner.on('plug-out', data => { Debug.IbctLogDbg(COMP, 'plug-out: ', data.devID); // miner.stopMining({ 'devId': data.devID }); }); miner.on("error", function (devID, data) { if (devID) Debug.IbctLogErr(COMP, 'Miner' + devID + ':', data); else Debug.IbctLogErr(COMP, data); }); miner.on("warning", function (devID, data) { if (devID) Debug.IbctLogDbg(COMP, 'Miner' + devID + ':', data); else Debug.IbctLogDbg(COMP, data); }); setTimeout(function() { if (mode === 1) { Debug.IbctLogDbg(COMP, 'Burn Image') fs.readFile('./recovery.bin', async (err, data) => { if (err) { Debug.IbctLogErr(COMP, err) } else { await miner.BurnMiningFirmware(null, data, function (err, data) { if (err) { Debug.IbctLogErr(COMP, err) return } Debug.IbctLogDbg(COMP, 'Burn ', (data * 100).toFixed(1), '%') if ((data * 100).toFixed(1) === '100.0') { Debug.IbctLogDbg(COMP, 'Burn Complete') } }) } }) } else if (mode === 2) { Debug.IbctLogDbg(COMP, 'Reboot') miner.RebootMining(null) } else if (mode === 3) { Debug.IbctLogDbg(COMP, 'Set led on') miner.SetMiningLed(null, true) setTimeout(function() { Debug.IbctLogDbg(COMP, 'Set led off') miner.SetMiningLed(null, false) }, 5000) } else if (mode === 4) { Debug.IbctLogDbg(COMP, 'Stop Miner') miner.stopMining(null) } else if (mode === 5) { Debug.IbctLogDbg(COMP, 'Exit Miner') miner.exitMining() } }, 10000) setInterval(function () { devState = miner.getMiningStatus(); Debug.IbctLogDbg(COMP, JSON.stringify(devState)); }, 10000); })();