UNPKG

intchains_ibctminer

Version:

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

91 lines (82 loc) 2.41 kB
const IntMiner = require('./src'); const Debug = require('./src/log')(); const fs = require('fs'); const COMP = '[SIPC]'; (async () => { var devState = [] var mode = 0 const miner = await IntMiner({ algoname: 'scrypt', minername: 'simplenode', cryptoname: 'sipc', protocolname: 'stratum' }); // init Mining await miner.initMining(); // set pool miner.setMiningConfig('pool', { host: `sipc.ss.dxpool.com`, port: 8008, user: `sunwei.b2`, pass: 'x' }) // start Mining await miner.startMining(null); miner.on('plug-in', data => { Debug.IbctLogDbg(COMP, 'plug-in: ', data.devID); 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 (data) { Debug.IbctLogErr(COMP, data); }); miner.on("warning", function (data) { Debug.IbctLogDbg(COMP, data); }); setTimeout(function() { if (mode === 1) { Debug.IbctLogDbg(COMP, 'Burn Image') fs.readFile('./v0.0.3r.bin', (err, data) => { if (err) { Debug.IbctLogErr(COMP, err) } else { 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); })();