mirror of https://github.com/BTCPrivate/z-nomp.git
commit
8a852b82ab
|
@ -25,7 +25,8 @@
|
|||
},
|
||||
"redis": {
|
||||
"host": "127.0.0.1",
|
||||
"port": 6379
|
||||
"port": 6379,
|
||||
"password": ""
|
||||
}
|
||||
},
|
||||
|
||||
|
|
|
@ -47,8 +47,10 @@ function SetupForPool(logger, poolOptions, setupFinished){
|
|||
|
||||
var logSystem = 'Payments';
|
||||
var logComponent = coin;
|
||||
|
||||
var opidCount = 0;
|
||||
|
||||
var opids = [];
|
||||
|
||||
// zcash team recommends 10 confirmations for safety from orphaned blocks
|
||||
var minConfShield = Math.max((processingConfig.minConf || 10), 1); // Don't allow 0 conf transactions.
|
||||
var minConfPayout = Math.max((processingConfig.minConf || 10), 1);
|
||||
|
@ -82,7 +84,9 @@ function SetupForPool(logger, poolOptions, setupFinished){
|
|||
logger[severity](logSystem, logComponent, message);
|
||||
});
|
||||
var redisClient = redis.createClient(poolOptions.redis.port, poolOptions.redis.host);
|
||||
|
||||
// redis auth if enabled
|
||||
redisClient.auth(poolOptions.redis.password);
|
||||
|
||||
var magnitude;
|
||||
var minPaymentSatoshis;
|
||||
var coinPrecision;
|
||||
|
@ -259,8 +263,10 @@ function SetupForPool(logger, poolOptions, setupFinished){
|
|||
callback(true);
|
||||
}
|
||||
else {
|
||||
var opid = (result.response || result[0].response);
|
||||
opidCount++;
|
||||
logger.special(logSystem, logComponent, 'Shield balance ' + amount);
|
||||
opids.push(opid);
|
||||
logger.special(logSystem, logComponent, 'Shield balance ' + amount + ' ' + opid);
|
||||
callback = function (){};
|
||||
callback(null);
|
||||
}
|
||||
|
@ -300,8 +306,10 @@ function SetupForPool(logger, poolOptions, setupFinished){
|
|||
callback(true);
|
||||
}
|
||||
else {
|
||||
var opid = (result.response || result[0].response);
|
||||
opidCount++;
|
||||
logger.special(logSystem, logComponent, 'Unshield funds for payout ' + amount);
|
||||
opids.push(opid);
|
||||
logger.special(logSystem, logComponent, 'Unshield funds for payout ' + amount + ' ' + opid);
|
||||
callback = function (){};
|
||||
callback(null);
|
||||
}
|
||||
|
@ -440,10 +448,12 @@ function SetupForPool(logger, poolOptions, setupFinished){
|
|||
// check operation id status
|
||||
if (op.status == "success" || op.status == "failed") {
|
||||
// clear operation id result
|
||||
batchRPC.push(['z_getoperationresult', [[op.id]]]);
|
||||
// clear operation id count
|
||||
if (opidCount > 0) {
|
||||
opidCount = 0;
|
||||
var opid_index = opids.indexOf(op.id);
|
||||
if (opid_index > -1) {
|
||||
// clear operation id count
|
||||
batchRPC.push(['z_getoperationresult', [[op.id]]]);
|
||||
opidCount--;
|
||||
opids.splice(opid_index, 1);
|
||||
}
|
||||
// log status to console
|
||||
if (op.status == "failed") {
|
||||
|
@ -498,8 +508,9 @@ function SetupForPool(logger, poolOptions, setupFinished){
|
|||
}
|
||||
if (err === true) {
|
||||
opidTimeout = setTimeout(checkOpids, opid_interval);
|
||||
if (opidCount > 0) {
|
||||
if (opidCount !== 0) {
|
||||
opidCount = 0;
|
||||
opids = [];
|
||||
logger.warning(logSystem, logComponent, 'Clearing operation ids due to RPC call errors.');
|
||||
}
|
||||
}
|
||||
|
@ -592,6 +603,10 @@ function SetupForPool(logger, poolOptions, setupFinished){
|
|||
serialized: r
|
||||
};
|
||||
});
|
||||
/* sort rounds by block hieght to pay in order */
|
||||
rounds.sort(function(a, b) {
|
||||
return a.height - b.height;
|
||||
});
|
||||
// find duplicate blocks by height
|
||||
// this can happen when two or more solutions are submitted at the same block height
|
||||
var duplicateFound = false;
|
||||
|
@ -755,14 +770,9 @@ function SetupForPool(logger, poolOptions, setupFinished){
|
|||
return true;
|
||||
};
|
||||
|
||||
// limit blocks paid per payment round
|
||||
// only pay max blocks at a time
|
||||
var payingBlocks = 0;
|
||||
//filter out all rounds that are immature (not confirmed or orphaned yet)
|
||||
rounds = rounds.filter(function(r){
|
||||
// only pay max blocks at a time
|
||||
if (payingBlocks >= maxBlocksPerPayment)
|
||||
return false;
|
||||
|
||||
switch (r.category) {
|
||||
case 'orphan':
|
||||
case 'kicked':
|
||||
|
@ -770,7 +780,7 @@ function SetupForPool(logger, poolOptions, setupFinished){
|
|||
return true;
|
||||
case 'generate':
|
||||
payingBlocks++;
|
||||
return true;
|
||||
return (payingBlocks <= maxBlocksPerPayment);
|
||||
|
||||
default:
|
||||
return false;
|
||||
|
@ -1280,10 +1290,7 @@ function SetupForPool(logger, poolOptions, setupFinished){
|
|||
|
||||
|
||||
var getProperAddress = function(address){
|
||||
if (address.length === 40){
|
||||
return util.addressFromEx(poolOptions.address, address);
|
||||
}
|
||||
else return address;
|
||||
return address;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -19,6 +19,8 @@ module.exports = function(logger){
|
|||
var proxySwitch = {};
|
||||
|
||||
var redisClient = redis.createClient(portalConfig.redis.port, portalConfig.redis.host);
|
||||
// redis auth if enabled
|
||||
redisClient.auth(portalConfig.redis.password);
|
||||
|
||||
//Handle messages from master process sent via IPC
|
||||
process.on('message', function(message) {
|
||||
|
@ -134,16 +136,6 @@ module.exports = function(logger){
|
|||
if (poolOptions.validateWorkerUsername !== true)
|
||||
authCallback(true);
|
||||
else {
|
||||
if (workerName.length === 40) {
|
||||
try {
|
||||
new Buffer(workerName, 'hex');
|
||||
authCallback(true);
|
||||
}
|
||||
catch (e) {
|
||||
authCallback(false);
|
||||
}
|
||||
}
|
||||
else {
|
||||
pool.daemon.cmd('validateaddress', [String(workerName).split(".")[0]], function (results) {
|
||||
var isValid = results.filter(function (r) {
|
||||
return r.response.isvalid
|
||||
|
@ -151,8 +143,7 @@ module.exports = function(logger){
|
|||
authCallback(isValid);
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
handlers.share = function(isValidShare, isValidBlock, data){
|
||||
|
|
|
@ -27,6 +27,9 @@ module.exports = function(logger, poolConfig){
|
|||
var logSubCat = 'Thread ' + (parseInt(forkId) + 1);
|
||||
|
||||
var connection = redis.createClient(redisConfig.port, redisConfig.host);
|
||||
// redis auth if needed
|
||||
connection.auth(redisConfig.password);
|
||||
|
||||
connection.on('ready', function(){
|
||||
logger.debug(logSystem, logComponent, logSubCat, 'Share processing setup with redis (' + redisConfig.host +
|
||||
':' + redisConfig.port + ')');
|
||||
|
|
|
@ -7,6 +7,13 @@ var os = require('os');
|
|||
|
||||
var algos = require('stratum-pool/lib/algoProperties.js');
|
||||
|
||||
// redis callback Ready check failed bypass trick
|
||||
function rediscreateClient(port, host, pass) {
|
||||
var client = redis.createClient(port, host);
|
||||
client.auth(pass);
|
||||
return client;
|
||||
}
|
||||
|
||||
function balanceRound(number) {
|
||||
return parseFloat((Math.round(number * 100000000) / 100000000).toFixed(8));
|
||||
}
|
||||
|
@ -80,14 +87,14 @@ module.exports = function(logger, portalConfig, poolConfigs){
|
|||
}
|
||||
redisClients.push({
|
||||
coins: [coin],
|
||||
client: redis.createClient(redisConfig.port, redisConfig.host)
|
||||
client: rediscreateClient(redisConfig.port, redisConfig.host, redisConfig.password)
|
||||
});
|
||||
});
|
||||
|
||||
function setupStatsRedis(){
|
||||
redisStats = redis.createClient(portalConfig.redis.port, portalConfig.redis.host);
|
||||
redisStats.on('error', function(err){
|
||||
logger.error(logSystem, 'Historics', 'Redis for stats had an error ' + JSON.stringify(err));
|
||||
redisStats.auth(portalConfig.redis.password);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -54,7 +54,6 @@ module.exports = function(logger){
|
|||
var keyScriptTemplate = '';
|
||||
var keyScriptProcessed = '';
|
||||
|
||||
|
||||
var processTemplates = function(){
|
||||
|
||||
for (var pageName in pageTemplates){
|
||||
|
@ -135,6 +134,7 @@ module.exports = function(logger){
|
|||
async.waterfall([
|
||||
function(callback){
|
||||
var client = redis.createClient(portalConfig.redis.port, portalConfig.redis.host);
|
||||
client.auth(portalConfig.redis.password);
|
||||
client.hgetall('coinVersionBytes', function(err, coinBytes){
|
||||
if (err){
|
||||
client.quit();
|
||||
|
|
Loading…
Reference in New Issue