Skip to content

Commit

Permalink
[ADDED] Payout Queue Limiter
Browse files Browse the repository at this point in the history
* [ADDED] LIMIT to getMPQueue and getAPQueue
* [ADDED] Default config payout queue size of 1000 for MP and 1000 for AP
* [UPDATED] Payouts cronjob to use this new default limits

This may help some coins that have tx count issues when doing sendmany.
Other coins can play with the values to find their sweet spot. Run the
payout multiple times in a row to force more transactions of the same
amount.

Fixes #1773 and thanks to @jrwr for the idea!
  • Loading branch information
MPOS123 committed Feb 18, 2014
1 parent cf8a10d commit 7229b5b
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 8 deletions.
4 changes: 2 additions & 2 deletions cronjobs/payouts.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
$dWalletBalance = 0;

// Fetch outstanding manual-payouts
$aManualPayouts = $transaction->getMPQueue();
$aManualPayouts = $transaction->getMPQueue($config['payout']['txlimit_manual']);

// Fetch our manual payouts, process them
if ($setting->getValue('disable_manual_payouts') != 1 && $aManualPayouts) {
Expand Down Expand Up @@ -117,7 +117,7 @@
$dWalletBalance = 0;

// Fetch outstanding auto-payouts
$aAutoPayouts = $transaction->getAPQueue();
$aAutoPayouts = $transaction->getAPQueue($config['payout']['txlimit_auto']);

// Fetch our auto payouts, process them
if ($setting->getValue('disable_auto_payouts') != 1 && $aAutoPayouts) {
Expand Down
14 changes: 8 additions & 6 deletions public/include/classes/transaction.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ public function getBalance($account_id) {
* @param none
* @return data array Account settings and confirmed balances
**/
public function getAPQueue() {
public function getAPQueue($limit=250) {
$this->debug->append("STA " . __METHOD__, 4);
$stmt = $this->mysqli->prepare("
SELECT
Expand All @@ -312,8 +312,9 @@ public function getAPQueue() {
ON t.account_id = a.id
WHERE t.archived = 0 AND a.ap_threshold > 0 AND a.coin_address IS NOT NULL AND a.coin_address != ''
GROUP BY t.account_id
HAVING confirmed > a.ap_threshold AND confirmed > " . $this->config['txfee_auto']);
if ($this->checkStmt($stmt) && $stmt->execute() && $result = $stmt->get_result())
HAVING confirmed > a.ap_threshold AND confirmed > " . $this->config['txfee_auto'] . "
LIMIT ?");
if ($this->checkStmt($stmt) && $stmt->bind_param('i', $limit) && $stmt->execute() && $result = $stmt->get_result())
return $result->fetch_all(MYSQLI_ASSOC);
return $this->sqlError();
}
Expand Down Expand Up @@ -377,7 +378,7 @@ private function createDebitRecord($account_id, $coin_address, $amount, $type) {
* @param none
* @return data Associative array with DB Fields
**/
public function getMPQueue() {
public function getMPQueue($limit=250) {
$stmt = $this->mysqli->prepare("
SELECT
a.id,
Expand All @@ -403,8 +404,9 @@ public function getMPQueue() {
ON t.block_id = b.id
WHERE p.completed = 0 AND t.archived = 0 AND a.coin_address IS NOT NULL AND a.coin_address != ''
GROUP BY t.account_id
HAVING confirmed > " . $this->config['txfee_manual']);
if ($this->checkStmt($stmt) && $stmt->execute() && $result = $stmt->get_result())
HAVING confirmed > " . $this->config['txfee_manual'] . "
LIMIT ?");
if ($this->checkStmt($stmt) && $stmt->bind_param('i', $limit) && $stmt->execute() && $result = $stmt->get_result())
return $result->fetch_all(MYSQLI_ASSOC);
return $this->sqlError('E0050');
}
Expand Down
7 changes: 7 additions & 0 deletions public/include/config/global.inc.dist.php
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,13 @@
**/
$config['sendmany']['enabled'] = false;

/**
* Transaction Limits
* Number of transactions per payout run
**/
$config['payout']['txlimit_manual'] = 1000;
$config['payout']['txlimit_auto'] = 1000;

/**
* Round Purging
* Round share purging configuration
Expand Down

0 comments on commit 7229b5b

Please sign in to comment.