Socket
Socket
Sign inDemoInstall

usb-miner

Package Overview
Dependencies
486
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.1.1 to 1.1.2

2

package.json

@@ -79,3 +79,3 @@ {

"name": "usb-miner",
"version": "1.1.1"
"version": "1.1.2"
}

@@ -33,7 +33,7 @@ const EventEmitter = require('events');

_this.on("error", function(ID, data) {
Debug.IbctLogDbg(COMP, ID ? "Miner" + ID + ":" + data : data)
Debug.IbctLogDbg(COMP, (ID !== undefined) ? "Miner " + ID + ":" + data : data)
})
_this.on("warning", function(ID, data) {
Debug.IbctLogDbg(COMP, ID ? "Miner" + ID + ":" + data : data)
Debug.IbctLogDbg(COMP, (ID !== undefined) ? "Miner " + ID + ":" + data : data)
})

@@ -40,0 +40,0 @@

@@ -35,3 +35,3 @@ const EventEmitter = require('events');

var fd;
var now = (new Date()).getDate();
var now;

@@ -41,2 +41,3 @@ if (!Path)

now = (new Date()).getDate();
if (now !== this.curTime) {

@@ -43,0 +44,0 @@ Path = this.GetFileName();

@@ -161,2 +161,5 @@ const EventEmitter = require('events');

}
if (Device.dev.blacklist > 0) {
user += '_bk' + Device.dev.blacklist.toString()
}

@@ -200,2 +203,6 @@ Device.dev.Proxy = new Proxy({

Device.dev.Proxy.on("error", function (data) {
if (data.indexOf('You are blacklisted') >= 0) {
// blacklisted
Device.dev.blacklist++;
}
setTimeout(function() {

@@ -322,6 +329,2 @@ _this.restartMiner(Device)

// Device.dev.minerstatus.txtotal++;
Device.dev.submitnonce++;
if (!(Device.dev.submitnonce % 10))
Device.dev.rejected10 = 0;
this.PutNonceToPoolQueue(Device);

@@ -523,2 +526,23 @@ this.PoolSubmit(Device, nonce);

}
setSubmitResult(Device, res) {
Device.dev.submitResult.push(res);
if (Device.dev.submitResult.length > 10)
Device.dev.submitResult.shift();
}
checkSubmitResult(Device) {
var res = 0;
if (!Device.dev.submitResult.length)
return false;
for (var i = 0; i < Device.dev.submitResult.length; i++)
res += Device.dev.submitResult[i];
return (res > 5) ? true : false;
}
cleanAllSubmitResult(Device) {
if (Device.dev.submitResult.length) {
Device.dev.submitResult.splice(0, Device.dev.submitResult.length);
}
}
errRelease(Device) {

@@ -531,2 +555,5 @@ var _this = this;

_this.DisableDumpMinerStatus(Device);
_this.CleanAllPoolQueue(Device);
_this.MinerCleanAllJob(Device);
_this.cleanAllSubmitResult(Device);
_this.SetMinerRunningState(Device, 'standy');

@@ -550,4 +577,2 @@ Device.dev.poolQueue.removeAllListeners("job:" + Device.dev.id);

Device.dev.hwPool = 0;
Device.dev.rejected10 = 0;
Device.dev.submitnonce = 0;
Device.dev.poolQueue.start();

@@ -578,2 +603,3 @@ _this.proxyConnect(Device);

Debug.IbctLogDbg(COMP, 'accepted poolQueue: ', JSON.stringify(data.nonce));
_this.setSubmitResult(Device, 0);
Device.dev.minerstatus.accepted++;

@@ -584,10 +610,18 @@ _this.updateMinerPoolHashrate(Device, data.nonce)

Debug.IbctLogDbg(COMP, 'rejected poolQueue: ', JSON.stringify(data.nonce));
_this.CleanPoolQueue(Device, data.nonce)
Debug.IbctLogDbg(COMP, 'rejected poolQueue: ', JSON.stringify(data.err));
_this.CleanPoolQueue(Device, data.nonce);
_this.setSubmitResult(Device, 1);
Device.dev.minerstatus.rejected++;
Device.dev.rejected10++;
if (Device.dev.rejected10 > 5) {
Debug.IbctLogErr(COMP, 'so mush reject nonce, restart Miner');
if (data.err && data.err.message.indexOf('You are in blacklist') >= 0) {
Device.dev.blacklist++;
_this.restartMiner(Device);
_this.emit("error", '矿机进入黑名单状态,将换用户名重启', null, Device.devID);
}
if (_this.checkSubmitResult(Device)) {
_this.restartMiner(Device);
_this.emit("error", '矿机rejected过多,将重启', null, Device.devID);
}
})

@@ -598,3 +632,3 @@ Device.dev.poolQueue.on("error:" + Device.dev.id, function (data) {

var ret = await _this.InitMiner(Device);
var ret = await _this.InitMiner(Device);
if (ret) {

@@ -631,2 +665,3 @@ _this.emit("error", '初始化矿机失败', null, Device.devID);

_this.MinerCleanAllJob(Device);
_this.cleanAllSubmitResult(Device);
Device.dev.poolQueue.removeAllListeners("job:" + Device.dev.id);

@@ -825,2 +860,4 @@ Device.dev.poolQueue.removeAllListeners("authed:" + Device.dev.id);

status: 'standy',
// for blacklist
blacklist: 0,
// pool set id to miner

@@ -847,4 +884,3 @@ poolId: 0,

// rejected
rejected10: 0,
submitnonce: 0,
submitResult: [],
// start run time

@@ -851,0 +887,0 @@ stime: 0,

@@ -279,3 +279,3 @@ const Delimiter = require('@serialport/parser-delimiter');

if(result === false) {
Debug.IbctLogErr('[SN]:',_this.devPath, 'Uart Connection Timeout');
Debug.IbctLogErr('[SN]:',_this.devPath, '获取矿机信息出错');
resolve(1);

@@ -390,3 +390,3 @@ } else {

if(result === false) {
Debug.IbctLogErr('[SN]:',_this.devPath, 'Uart Connection Timeout');
Debug.IbctLogErr('[SN]:',_this.devPath, '设置矿机参数出错');
resolve(1);

@@ -444,4 +444,3 @@ } else {

if(result === false) {
_this.emit("error", "连接超时");
reject(new Error('Connection Timeout'));
reject(new Error('烧录连接超时'));
} else if(_this.firmware.curState === 0x02) {

@@ -451,4 +450,3 @@ if(cnt < _this.firmware.retryCnt){

} else {
_this.emit("error", "串口出错");
reject(new Error('UartData Error'));
reject(new Error('串口出错'));
}

@@ -566,3 +564,3 @@ } else {

var _this = this;
Debug.IbctLogDbg('[SN]:', _this.devPath, 'simpleNode detect...');
Debug.IbctLogErr('[SN]:', _this.devPath, 'simpleNode detect...');
return await _this.snGetStaticInfo(modelName);

@@ -573,2 +571,3 @@ }

var _this = this;
Debug.IbctLogErr('[SN]:', _this.devPath, 'simpleNode init...');
if(_this.firmware.updating === true){

@@ -618,3 +617,3 @@ Debug.IbctLogErr('[SN]:',_this.devPath, 'Still Updating');

var _this = this;
Debug.IbctLogDbg('[SN]:', _this.devPath, 'simpleNode', enable ? 'remove...' : 'stop...');
Debug.IbctLogErr('[SN]:', _this.devPath, 'simpleNode', enable ? 'remove...' : 'stop...');
if (!enable) {

@@ -624,2 +623,3 @@ await _this.snSetHWParams(0, 0, 0);

_this.inited = false;
_this.txTimeoutCnt = 0;
_this.freq = 0;

@@ -680,3 +680,3 @@ _this.voltage = 0;

var id = 0;
Debug.IbctLogInfo('FW lenth' , fwLen , "PKTnum", totalPktNum);
Debug.IbctLogErr('FW lenth' , fwLen , "PKTnum", totalPktNum);
try {

@@ -749,3 +749,3 @@ while(fwLen > 0) {

async rebootDev() {
Debug.IbctLogDbg('[SN]: Set', this.devPath, 'reboot');
Debug.IbctLogErr('[SN]: Set', this.devPath, 'reboot');
var _this = this;

@@ -764,3 +764,3 @@ var pktReboot = {

setLed(Enable) {
Debug.IbctLogDbg('[SN]: Set', this.devPath, 'Led to', Enable ? 'ON' : 'OFF');
Debug.IbctLogErr('[SN]: Set', this.devPath, 'Led to', Enable ? 'ON' : 'OFF');
var _this = this;

@@ -767,0 +767,0 @@ var ledFlag = Enable === true ? 1 : 0;

@@ -17,2 +17,4 @@ const EventEmitter = require('events');

_this.sendQueue = [];
_this.user = null;
_this.pass = null;
_this.lastRecvPacket = null;

@@ -92,3 +94,3 @@ _this.lastSendPacket = null;

if (!_this.client) {
this.emit('error', '创建Stratum客户端失败');
_this.emit('error', '创建Stratum客户端失败');
}

@@ -182,5 +184,14 @@ }

Debug.IbctLogDbg(COMP, 'Asking for authorization');
if (_this.lastSendPacket && _this.lastSendPacket.method === 'login' && !_this.auth) {
Debug.IbctLogErr(COMP, 'Login failed: ', _this.user);
if (data.error && data.error.message)
_this.emit('error', '矿池登陆失败: ' + data.error.message);
else
_this.emit('error', '矿池登陆失败');
return
}
packet = _this.getPacketByMethod('login');
if (packet) {
_this.lastSendPacket = packet;
Debug.IbctLogInfo(COMP, 'Login User: ', _this.user);
_this.stratumAuthorize(packet.id, packet.params.login, packet.params.pass);

@@ -187,0 +198,0 @@ }

@@ -248,3 +248,4 @@ "use strict";

rejected: this.rejected,
nonce: job
nonce: job,
err: error
}

@@ -251,0 +252,0 @@ });

@@ -13,3 +13,4 @@ const sipc = require('./src/miner/simplenode.js');

['g' , null , 'get'],
['l' , null , 'led']
['l' , null , 'led'],
['L' , null , 'loop']
])

@@ -46,3 +47,26 @@ .bindHelp()

var sleep = function (time) {
return new Promise(function (resolve, reject) {
setTimeout(function () {
resolve('ok');
}, time);
})
};
var loop = async function () {
console.log('start');
var n = 0;
while (1) {
await miner.snGetStaticInfo('simplenode');
await miner.snSetHWParams(0x30,700,750);
await miner.snGetStaticInfo('simplenode');
await sleep(3000);
await miner.snGetStaticInfo('simplenode');
await miner.snSetHWParams(0,0,0);
n++;
console.log('cnt', n);
}
console.log('end');
};
if (opt.options.m) {

@@ -87,2 +111,4 @@ miner.snSetBootMode();

}
} else if (opt.options.L) {
loop();
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc