@@ -0,0 +1,4 @@ | |||
Your payout level has been changed on %POOL_HOST% pool. | |||
You can can edit your payout levels by visiting the pool's web interface at: | |||
https://%POOL_HOST%/#settings |
@@ -299,7 +299,7 @@ function handleSetMinerPayoutLevel(urlParts, response){ | |||
} | |||
if (level < 0 || level > 100) { | |||
response.end(JSON.stringify({'status': 'Please chose a level between 0 and 100'})); | |||
response.end(JSON.stringify({'status': 'Please choose a level between 0 and 100'})); | |||
return; | |||
} | |||
@@ -311,15 +311,16 @@ function handleSetMinerPayoutLevel(urlParts, response){ | |||
return; | |||
} | |||
redisClient.hset(config.coin + ':payout_level' , address, level, function(error, value){ | |||
redisClient.hset(config.coin + ':workers:' + address, 'minPayoutLevel', level, function(error, value){ | |||
if (error){ | |||
response.end(JSON.stringify({'status': 'woops something failed'})); | |||
return; | |||
} | |||
//emailSystem.notifyAddress(address, 'Your email was registered', 'email_added'); | |||
log('info', logSystem, 'Updated payout level for address ' + address + ' level: ' + level); | |||
emailSystem.notifyAddress(address, 'Your payout level changed to: ' + level', 'payout_level_changed'); | |||
response.end(JSON.stringify({'status': 'done'})); | |||
}); | |||
log('info', logSystem, 'Updated payout level for address ' + address + ' level: ' + level); | |||
}); | |||
} | |||
@@ -333,19 +334,18 @@ function handleGetMinerPayoutLevel(urlParts, response){ | |||
response.write('\n'); | |||
var address = urlParts.query.address; | |||
// Check the minimal required parameters for this handle. | |||
if (address == undefined) { | |||
response.end(JSON.stringify({'status': 'parameters are incomplete'})); | |||
return; | |||
} | |||
redisClient.hget(config.coin + ':payout_level', address, function(error, value){ | |||
redisClient.hget(config.coin + ':workers:' + address, 'minPayoutLevel' function(error, value){ | |||
if (error){ | |||
response.end(JSON.stringify({'level': 'woops something failed'})); | |||
response.end(JSON.stringify({'status': 'woops something failed'})); | |||
return; | |||
} | |||
response.end(JSON.stringify({'level': value})); | |||
response.end(JSON.stringify({'status': 'done', 'level': value})); | |||
return; | |||
}); | |||
} | |||
@@ -31,7 +31,7 @@ function runInterval(){ | |||
//Get worker balances | |||
function(keys, callback){ | |||
var redisCommands = keys.map(function(k){ | |||
return ['hget', k, 'balance']; | |||
return ['hmget', k, 'balance', 'minPayoutLevel]; | |||
}); | |||
redisClient.multi(redisCommands).exec(function(error, replies){ | |||
if (error){ | |||
@@ -40,30 +40,32 @@ function runInterval(){ | |||
return; | |||
} | |||
var balances = {}; | |||
var minPayoutLevel = {}; | |||
for (var i = 0; i < replies.length; i++){ | |||
var parts = keys[i].split(':'); | |||
var workerId = parts[parts.length - 1]; | |||
balances[workerId] = parseInt(replies[i]) || 0 | |||
data = replies[i]; | |||
balances[workerId] = parseInt(data[0]) || 0 | |||
minPayoutLevel[workerId] = parseInt(data[1]) || config.payments.minPayment | |||
} | |||
callback(null, balances); | |||
callback(null, balances, minPayoutLevel); | |||
}); | |||
}, | |||
//Filter workers under balance threshold for payment | |||
function(balances, callback){ | |||
function(balances, minPayoutLevel, callback){ | |||
var payments = {}; | |||
for (var worker in balances){ | |||
var balance = balances[worker]; | |||
if (balance >= config.payments.minPayment){ | |||
if (balance >= minPayoutLevel[worker]){ | |||
var remainder = balance % config.payments.denomination; | |||
var payout = balance - remainder; | |||
// if use dynamic transfer fee, fee will be subtracted from miner's payout | |||
if(config.payments.useDynamicTransferFee && config.payments.minerPayFee){ | |||
payout -= config.payments.transferFeePerPayee; | |||
} | |||
// if use dynamic transfer fee, fee will be subtracted from miner's payout | |||
if(config.payments.useDynamicTransferFee && config.payments.minerPayFee){ | |||
payout -= config.payments.transferFeePerPayee; | |||
} | |||
if (payout < 0) continue; | |||
payments[worker] = payout; | |||
} | |||