Payment Update

Moving payment timers into the database
Adding the last payment timer cycle to the stats
This commit is contained in:
Alexander Blair
2017-02-26 10:20:11 -08:00
parent 194ca829f5
commit 3fab1673ff
3 changed files with 24 additions and 6 deletions
+3 -2
View File
@@ -75,7 +75,8 @@ app.get('/pool/stats', function (req, res) {
let localCache = global.database.getCache('pool_stats_global');
delete(localCache.minerHistory);
delete(localCache.hashHistory);
res.json({pool_list: pool_list, pool_statistics: localCache});
let lastPayment = global.database.getCache('lastPaymentCycle');
res.json({pool_list: pool_list, pool_statistics: localCache, last_payment: !lastPayment ? 0 : lastPayment});
});
app.get('/pool/chart/hashrate', function (req, res) {
@@ -601,7 +602,7 @@ adminRoutes.get('/stats', function (req, res) {
});
return callback(null);
}
], function (err) {
], function () {
return res.json(intCache);
});
});
+5 -4
View File
@@ -307,7 +307,7 @@ let paymentQueue = async.queue(function (paymentDetails, callback) {
if(!extraPaymentRound){
setTimeout(function(){
makePayments();
}, 1800000);
}, global.config.payout.timerRetry * 60 * 1000);
}
extraPaymentRound = true;
return callback(false);
@@ -342,7 +342,8 @@ let paymentQueue = async.queue(function (paymentDetails, callback) {
paymentQueue.drain = function(){
extraPaymentRound = false;
paymentTimer = setInterval(makePayments, 7200000);
paymentTimer = setInterval(makePayments, global.config.payout.timer * 60 * 1000);
global.database.setCache('lastPaymentCycle', Math.floor(Date.now()/1000));
};
function updateShapeshiftCompletion() {
@@ -638,7 +639,7 @@ function makePayments() {
mixin: global.config.payout.mixIn
};
console.log("Paying out: " + paymentDetails.destinations.length + " people");
paymentQueue.push(paymentDetails, function (body) {
paymentQueue.push(paymentDetails, function (body) { //jshint ignore:line
// This is the only section that could potentially contain multiple txns. Lets do this safely eh?
if (body.fee && body.fee > 10) {
debug("Made it to the SQL insert for transactions");
@@ -683,7 +684,7 @@ function init() {
});
}, 60000);
setInterval(determineBestExchange, 60000);
paymentTimer = setInterval(makePayments, 7200000);
console.log("Setting the payment timer to: " + global.config.payout.timer + " minutes with a: " + global.config.timerRetry + " minute delay if the wallet is out of money");
makePayments();
}