Work on payment processing
This commit is contained in:
parent
916201f128
commit
e62293ed2e
|
@ -80,17 +80,21 @@ function SetupForPool(logger, poolOptions){
|
||||||
daemon.cmd('gettransaction', [tx], function(results){
|
daemon.cmd('gettransaction', [tx], function(results){
|
||||||
//console.dir(results[0].response.details[0].category);
|
//console.dir(results[0].response.details[0].category);
|
||||||
var status = 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 balances_coin from redis for each address in this round
|
||||||
- get contributed shares
|
//add up total balances
|
||||||
- get unsent payments
|
//send necessary payments
|
||||||
- calculate payments
|
//put left over balances in redis
|
||||||
- send payments
|
//clean up (move block entry to processedBlocks_coin) so this logic isn't called again
|
||||||
- put unsent payments in db
|
|
||||||
- remove tx from db
|
});
|
||||||
- remove shares from db
|
|
||||||
*/
|
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -52,12 +52,15 @@ module.exports = function(logger, poolConfig){
|
||||||
|
|
||||||
if (!isValidShare) return;
|
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)
|
if (error)
|
||||||
logger.error('redis', 'Could not store worker share')
|
logger.error('redis', 'Could not store worker share')
|
||||||
});
|
});
|
||||||
|
|
||||||
if (isValidBlock){
|
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){
|
connection.sadd(['blocks_' + coin, shareData.tx + ':' + shareData.height], function(error, result){
|
||||||
if (error)
|
if (error)
|
||||||
logger.error('redis', 'Could not store block data');
|
logger.error('redis', 'Could not store block data');
|
||||||
|
|
Loading…
Reference in New Issue