Update paymentProcessor.js

Sort rounds during payments so blocks are paid in order.
Optimization to max blocks per payment logic.
This commit is contained in:
hellcatz 2017-08-02 19:26:32 -07:00 committed by GitHub
parent f6f6f0c712
commit f2786e7a5b
1 changed files with 6 additions and 7 deletions

View File

@ -592,6 +592,10 @@ function SetupForPool(logger, poolOptions, setupFinished){
serialized: r
};
});
/* sort rounds by block hieght to pay in order */
rounds.sort(function(a, b) {
return a.height - b.height;
});
// find duplicate blocks by height
// this can happen when two or more solutions are submitted at the same block height
var duplicateFound = false;
@ -755,14 +759,9 @@ function SetupForPool(logger, poolOptions, setupFinished){
return true;
};
// limit blocks paid per payment round
// only pay max blocks at a time
var payingBlocks = 0;
//filter out all rounds that are immature (not confirmed or orphaned yet)
rounds = rounds.filter(function(r){
// only pay max blocks at a time
if (payingBlocks >= maxBlocksPerPayment)
return false;
switch (r.category) {
case 'orphan':
case 'kicked':
@ -770,7 +769,7 @@ function SetupForPool(logger, poolOptions, setupFinished){
return true;
case 'generate':
payingBlocks++;
return true;
return (payingBlocks < maxBlocksPerPayment);
default:
return false;