Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update paymentProcessor.js #639

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions libs/paymentProcessor.js
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,31 @@ function SetupForPool(logger, poolOptions, setupFinished){
var addressAmounts = {};
var totalSent = 0;
for (var w in workers) {

// LeshaCat: If the address is not valid, skip calculation
// for all workers and callback() to resume
// https://github.com/foxer666/node-open-mining-portal/issues/145
// *!*UNTESTED *!* due to different code base, this was modified (again)
var isValid = function() {
daemon.cmd('validateaddress', [address], function(results) {
if (result.error || !result.response){
logger.error('Skipping validation, error with payment processing daemon ' + JSON.stringify(result.error));
return true;
}
else if (!result.response.isvalid) {
logger.error('Address is not valid: ' + JSON.stringify(result.response));
return false;
}
else{
return false;
}
}, true);
}
if (!isValid) {
callback(null, workers, rounds);
Copy link
Author

@mooleshacat mooleshacat Oct 31, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the only line I am unsure about. Do I just return; or do I callback and then return; to skip the worker?

If we are looping through only workers for one payout address, I believe we want both.
If we are looping through all workers for every payout address, I believe we want only "return;"

return;
}

var worker = workers[w];
worker.balance = worker.balance || 0;
worker.reward = worker.reward || 0;
Expand All @@ -385,6 +410,7 @@ function SetupForPool(logger, poolOptions, setupFinished){
worker.balanceChange = Math.max(toSend - worker.balance, 0);
worker.sent = 0;
}

}

if (Object.keys(addressAmounts).length === 0){
Expand Down