Added "poolServer.fixedDiff" option in /config.json
Set difficulty on miner client side by passing <address> param with .<difficulty> postfix For example: minerd -u 4AsBy39rpUMTmgTUARGq2bFQWhDhdQNekK5v4uaLU699NPAnx9CubEJ82AkvD5ScoAZNYRwBxybayainhyThHAZWCdKmPYn.5000pull/3/head
parent
5a13122cd6
commit
c2a9aae907
|
@ -201,6 +201,13 @@ Explanation for each field:
|
|||
"maxJump": 100 //Limit diff percent increase/decrease in a single retargetting
|
||||
},
|
||||
|
||||
/* Set difficulty on miner client side by passing <address> param with .<difficulty> postfix
|
||||
minerd -u 4AsBy39rpUMTmgTUARGq2bFQWhDhdQNekK5v4uaLU699NPAnx9CubEJ82AkvD5ScoAZNYRwBxybayainhyThHAZWCdKmPYn.5000 */
|
||||
"fixedDiff": {
|
||||
"enabled": true,
|
||||
"separator": ".", // character separator between <address> and <difficulty>
|
||||
},
|
||||
|
||||
/* Feature to trust share difficulties from miners which can
|
||||
significantly reduce CPU load. */
|
||||
"shareTrust": {
|
||||
|
|
10
config.json
10
config.json
|
@ -44,13 +44,17 @@
|
|||
}
|
||||
],
|
||||
"varDiff": {
|
||||
"minDiff": 2,
|
||||
"maxDiff": 100000,
|
||||
"minDiff": 100,
|
||||
"maxDiff": 200000,
|
||||
"targetTime": 100,
|
||||
"retargetTime": 30,
|
||||
"variancePercent": 30,
|
||||
"maxJump": 100
|
||||
},
|
||||
"fixedDiff": {
|
||||
"enabled": true,
|
||||
"addressSeparator": "."
|
||||
},
|
||||
"shareTrust": {
|
||||
"enabled": true,
|
||||
"min": 10,
|
||||
|
@ -110,4 +114,4 @@
|
|||
"host": "127.0.0.1",
|
||||
"port": 6379
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
34
lib/pool.js
34
lib/pool.js
|
@ -47,7 +47,9 @@ setInterval(function(){
|
|||
var now = Date.now() / 1000 | 0;
|
||||
for (var minerId in connectedMiners){
|
||||
var miner = connectedMiners[minerId];
|
||||
miner.retarget(now);
|
||||
if(!miner.noRetarget) {
|
||||
miner.retarget(now);
|
||||
}
|
||||
}
|
||||
}, config.poolServer.varDiff.retargetTime * 1000);
|
||||
|
||||
|
@ -190,13 +192,14 @@ var VarDiff = (function(){
|
|||
};
|
||||
})();
|
||||
|
||||
function Miner(id, login, pass, ip, startingDiff, pushMessage){
|
||||
function Miner(id, login, pass, ip, startingDiff, noRetarget, pushMessage){
|
||||
this.id = id;
|
||||
this.login = login;
|
||||
this.pass = pass;
|
||||
this.ip = ip;
|
||||
this.pushMessage = pushMessage;
|
||||
this.heartbeat();
|
||||
this.noRetarget = noRetarget;
|
||||
this.difficulty = startingDiff;
|
||||
this.validJobs = [];
|
||||
|
||||
|
@ -452,11 +455,28 @@ function handleMinerMethod(method, params, ip, portData, sendReply, pushMessage)
|
|||
|
||||
switch(method){
|
||||
case 'login':
|
||||
if (!params.login){
|
||||
var login = params.login;
|
||||
if (!login){
|
||||
sendReply('missing login');
|
||||
return;
|
||||
}
|
||||
if (addressBase58Prefix !== cnUtil.address_decode(new Buffer(params.login))){
|
||||
|
||||
var difficulty = portData.difficulty;
|
||||
var noRetarget = false;
|
||||
if(config.poolServer.fixedDiff.enabled) {
|
||||
var fixedDiffCharPos = login.indexOf(config.poolServer.fixedDiff.addressSeparator);
|
||||
if(fixedDiffCharPos != -1) {
|
||||
noRetarget = true;
|
||||
difficulty = login.substr(fixedDiffCharPos + 1);
|
||||
if(difficulty < config.poolServer.varDiff.minDiff) {
|
||||
difficulty = config.poolServer.varDiff.minDiff;
|
||||
}
|
||||
login = login.substr(0, fixedDiffCharPos);
|
||||
log('info', logSystem, 'Miner difficulty fixed to %s', [difficulty]);
|
||||
}
|
||||
}
|
||||
|
||||
if (addressBase58Prefix !== cnUtil.address_decode(new Buffer(login))){
|
||||
sendReply('invalid address used for login');
|
||||
return;
|
||||
}
|
||||
|
@ -465,7 +485,7 @@ function handleMinerMethod(method, params, ip, portData, sendReply, pushMessage)
|
|||
return;
|
||||
}
|
||||
var minerId = utils.uid();
|
||||
miner = new Miner(minerId, params.login, params.pass, ip, portData.difficulty, pushMessage);
|
||||
miner = new Miner(minerId, login, params.pass, ip, difficulty, noRetarget, pushMessage);
|
||||
connectedMiners[minerId] = miner;
|
||||
sendReply(null, {
|
||||
id: minerId,
|
||||
|
@ -659,7 +679,3 @@ function startPoolServerTcp(callback){
|
|||
callback(true);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue