mirror of
https://github.com/jwinterm/nodejs-pool.git
synced 2026-10-17 05:21:27 +02:00
Update to include roundHashes
Update to fix an API bug with identifiers Moving payments that fail due to $$ to retry in 30 minutes - Need to block if it's payment ID based.
This commit is contained in:
+5
-2
@@ -300,7 +300,7 @@ app.get('/miner/:address/payments', function (req, res) {
|
||||
|
||||
app.get('/miner/:address/stats/allWorkers', function (req, res) {
|
||||
let address = req.params.address;
|
||||
let identifiers = global.database.getCache(address + '_identifiers').sort();
|
||||
let identifiers = global.database.getCache(address + '_identifiers')
|
||||
let globalCache = global.database.getCache(address);
|
||||
let returnData = {global: {
|
||||
lts: Math.floor(globalCache.lastHash / 1000),
|
||||
@@ -309,7 +309,10 @@ app.get('/miner/:address/stats/allWorkers', function (req, res) {
|
||||
totalHash: globalCache.totalHashes
|
||||
}};
|
||||
let intCounter = 0;
|
||||
identifiers.forEach(function(identifier){
|
||||
if (identifiers === false){
|
||||
return res.json(returnData);
|
||||
}
|
||||
identifiers.sort().forEach(function(identifier){
|
||||
let cachedData = global.database.getCache(req.params.address+"_"+identifier);
|
||||
returnData[identifier] = {
|
||||
lts: Math.floor(cachedData.lastHash / 1000),
|
||||
|
||||
+21
-5
@@ -61,7 +61,11 @@ function Database(){
|
||||
if (!cached.hasOwnProperty(intDict.location)){
|
||||
cached[intDict.location] = 0;
|
||||
}
|
||||
cached[intDict.location] += intDict.value;
|
||||
if (intDict.value === false){
|
||||
cached[intDict.location] = 0;
|
||||
} else {
|
||||
cached[intDict.location] += intDict.value;
|
||||
}
|
||||
});
|
||||
txn.putString(this.cacheDB, key, JSON.stringify(cached));
|
||||
txn.commit();
|
||||
@@ -150,16 +154,16 @@ function Database(){
|
||||
minerID = minerID + '.' + share.paymentID;
|
||||
}
|
||||
let minerIDWithIdentifier = minerID + "_" + share.identifier;
|
||||
this.incrementCacheData('global_stats', [{location: 'totalHashes', value: share.shares}]);
|
||||
this.incrementCacheData('global_stats', [{location: 'totalHashes', value: share.shares}, {location: 'roundHashes', value: share.shares}]);
|
||||
switch (share.poolType) {
|
||||
case global.protos.POOLTYPE.PPLNS:
|
||||
this.incrementCacheData('pplns_stats', [{location: 'totalHashes', value: share.shares}]);
|
||||
this.incrementCacheData('pplns_stats', [{location: 'totalHashes', value: share.shares}, {location: 'roundHashes', value: share.shares}]);
|
||||
break;
|
||||
case global.protos.POOLTYPE.PPS:
|
||||
this.incrementCacheData('pps_stats', [{location: 'totalHashes', value: share.shares}]);
|
||||
this.incrementCacheData('pps_stats', [{location: 'totalHashes', value: share.shares}, {location: 'roundHashes', value: share.shares}]);
|
||||
break;
|
||||
case global.protos.POOLTYPE.SOLO:
|
||||
this.incrementCacheData('solo_stats', [{location: 'totalHashes', value: share.shares}]);
|
||||
this.incrementCacheData('solo_stats', [{location: 'totalHashes', value: share.shares}, {location: 'roundHashes', value: share.shares}]);
|
||||
break;
|
||||
}
|
||||
this.incrementCacheData(minerIDWithIdentifier, [{location: 'totalHashes', value: share.shares},{location: 'goodShares', value: 1}]);
|
||||
@@ -255,6 +259,18 @@ function Database(){
|
||||
let txn = global.database.env.beginTxn();
|
||||
txn.putBinary(global.database.blockDB, blockId, blockData);
|
||||
txn.commit();
|
||||
global.database.incrementCacheData('global_stats', [{location: 'roundHashes', value: false}]);
|
||||
switch (blockDataDecoded.poolType) {
|
||||
case global.protos.POOLTYPE.PPLNS:
|
||||
global.database.incrementCacheData('pplns_stats', [{location: 'roundHashes', value: false}]);
|
||||
break;
|
||||
case global.protos.POOLTYPE.PPS:
|
||||
global.database.incrementCacheData('pps_stats', [{location: 'roundHashes', value: false}]);
|
||||
break;
|
||||
case global.protos.POOLTYPE.SOLO:
|
||||
global.database.incrementCacheData('solo_stats', [{location: 'roundHashes', value: false}]);
|
||||
break;
|
||||
}
|
||||
return callback(true);
|
||||
});
|
||||
} catch (e) {
|
||||
|
||||
@@ -298,6 +298,9 @@ let paymentQueue = async.queue(function (paymentDetails, callback) {
|
||||
if (body.hasOwnProperty('error')) {
|
||||
if (body.error.message === "not enough money"){
|
||||
console.error("Issue making payments, not enough money, will try later");
|
||||
setTimeout(function(){
|
||||
paymentQueue.push(paymentDetails, callback);
|
||||
}, 1800000);
|
||||
return callback(false);
|
||||
} else {
|
||||
console.error("Issue making payments" + JSON.stringify(body.error));
|
||||
|
||||
+9
-1
@@ -317,6 +317,13 @@ function updatePoolStats(poolType) {
|
||||
});
|
||||
}
|
||||
},
|
||||
function (callback) {
|
||||
debug(threadName + "Checking Influx for last 10min avg for miner count for pool stats");
|
||||
if (typeof(poolType) !== 'undefined') {
|
||||
return callback(null, global.database.getCache(poolType + "_stats").roundHashes || 0);
|
||||
}
|
||||
return callback(null, global.database.getCache("global_stats").roundHashes || 0);
|
||||
}
|
||||
], function (err, result) {
|
||||
if (typeof(poolType) === 'undefined') {
|
||||
poolType = 'global';
|
||||
@@ -329,7 +336,8 @@ function updatePoolStats(poolType) {
|
||||
lastBlockFound: result[4] || 0,
|
||||
totalBlocksFound: result[5] || 0,
|
||||
totalMinersPaid: result[6] || 0,
|
||||
totalPayments: result[7] || 0
|
||||
totalPayments: result[7] || 0,
|
||||
roundHashes: result[8] || 0
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user