diff --git a/libs/paymentProcessor.js b/libs/paymentProcessor.js index 2813a5c..776edc1 100644 --- a/libs/paymentProcessor.js +++ b/libs/paymentProcessor.js @@ -80,17 +80,21 @@ function SetupForPool(logger, poolOptions){ daemon.cmd('gettransaction', [tx], function(results){ //console.dir(results[0].response.details[0].category); var status = results[0].response.details[0].category; - var confirmed = (status === 'generate'); + var amount = results[0].response.details[0].amount; + if (status !== 'generate') return; + var f = 'shares_' + coin + ':round' + blockHeight; + console.log(f); + redisClient.hgetall('shares_' + coin + ':round' + blockHeight, function(error, results){ + if (error || !results) return; + console.log('okay ' + JSON.stringify(results)); - /* next: - - get contributed shares - - get unsent payments - - calculate payments - - send payments - - put unsent payments in db - - remove tx from db - - remove shares from db - */ + //get balances_coin from redis for each address in this round + //add up total balances + //send necessary payments + //put left over balances in redis + //clean up (move block entry to processedBlocks_coin) so this logic isn't called again + + }); }); }; diff --git a/libs/shareProcessor.js b/libs/shareProcessor.js index 43faee5..1d51afd 100644 --- a/libs/shareProcessor.js +++ b/libs/shareProcessor.js @@ -52,12 +52,15 @@ module.exports = function(logger, poolConfig){ if (!isValidShare) return; - connection.hincrby(['shares_' + coin + ':' + shareData.height, shareData.worker, shareData.difficulty], function(error, result){ + connection.hincrby(['shares_' + coin + ':roundCurrent', shareData.worker, shareData.difficulty], function(error, result){ if (error) logger.error('redis', 'Could not store worker share') }); if (isValidBlock){ + connection.rename('shares_' + coin + ':roundCurrent', 'shares_' + coin + ':round' + shareData.height, function(result){ + console.log('rename result: ' + result); + }); connection.sadd(['blocks_' + coin, shareData.tx + ':' + shareData.height], function(error, result){ if (error) logger.error('redis', 'Could not store block data');