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:
Alexander Blair
2017-02-15 18:49:12 -08:00
parent aa0353868c
commit bf730fddbe
4 changed files with 38 additions and 8 deletions
+5 -2
View File
@@ -300,7 +300,7 @@ app.get('/miner/:address/payments', function (req, res) {
app.get('/miner/:address/stats/allWorkers', function (req, res) { app.get('/miner/:address/stats/allWorkers', function (req, res) {
let address = req.params.address; 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 globalCache = global.database.getCache(address);
let returnData = {global: { let returnData = {global: {
lts: Math.floor(globalCache.lastHash / 1000), lts: Math.floor(globalCache.lastHash / 1000),
@@ -309,7 +309,10 @@ app.get('/miner/:address/stats/allWorkers', function (req, res) {
totalHash: globalCache.totalHashes totalHash: globalCache.totalHashes
}}; }};
let intCounter = 0; 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); let cachedData = global.database.getCache(req.params.address+"_"+identifier);
returnData[identifier] = { returnData[identifier] = {
lts: Math.floor(cachedData.lastHash / 1000), lts: Math.floor(cachedData.lastHash / 1000),
+21 -5
View File
@@ -61,7 +61,11 @@ function Database(){
if (!cached.hasOwnProperty(intDict.location)){ if (!cached.hasOwnProperty(intDict.location)){
cached[intDict.location] = 0; 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.putString(this.cacheDB, key, JSON.stringify(cached));
txn.commit(); txn.commit();
@@ -150,16 +154,16 @@ function Database(){
minerID = minerID + '.' + share.paymentID; minerID = minerID + '.' + share.paymentID;
} }
let minerIDWithIdentifier = minerID + "_" + share.identifier; 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) { switch (share.poolType) {
case global.protos.POOLTYPE.PPLNS: 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; break;
case global.protos.POOLTYPE.PPS: 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; break;
case global.protos.POOLTYPE.SOLO: 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; break;
} }
this.incrementCacheData(minerIDWithIdentifier, [{location: 'totalHashes', value: share.shares},{location: 'goodShares', value: 1}]); this.incrementCacheData(minerIDWithIdentifier, [{location: 'totalHashes', value: share.shares},{location: 'goodShares', value: 1}]);
@@ -255,6 +259,18 @@ function Database(){
let txn = global.database.env.beginTxn(); let txn = global.database.env.beginTxn();
txn.putBinary(global.database.blockDB, blockId, blockData); txn.putBinary(global.database.blockDB, blockId, blockData);
txn.commit(); 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); return callback(true);
}); });
} catch (e) { } catch (e) {
+3
View File
@@ -298,6 +298,9 @@ let paymentQueue = async.queue(function (paymentDetails, callback) {
if (body.hasOwnProperty('error')) { if (body.hasOwnProperty('error')) {
if (body.error.message === "not enough money"){ if (body.error.message === "not enough money"){
console.error("Issue making payments, not enough money, will try later"); console.error("Issue making payments, not enough money, will try later");
setTimeout(function(){
paymentQueue.push(paymentDetails, callback);
}, 1800000);
return callback(false); return callback(false);
} else { } else {
console.error("Issue making payments" + JSON.stringify(body.error)); console.error("Issue making payments" + JSON.stringify(body.error));
+9 -1
View File
@@ -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) { ], function (err, result) {
if (typeof(poolType) === 'undefined') { if (typeof(poolType) === 'undefined') {
poolType = 'global'; poolType = 'global';
@@ -329,7 +336,8 @@ function updatePoolStats(poolType) {
lastBlockFound: result[4] || 0, lastBlockFound: result[4] || 0,
totalBlocksFound: result[5] || 0, totalBlocksFound: result[5] || 0,
totalMinersPaid: result[6] || 0, totalMinersPaid: result[6] || 0,
totalPayments: result[7] || 0 totalPayments: result[7] || 0,
roundHashes: result[8] || 0
}); });
}); });
} }