mirror of
https://github.com/LBRYFoundation/pool.git
synced 2025-08-23 09:27:25 +00:00
backend: avoid to clear earnings during payouts (#249)
+ simplify payment code based on RavenMinerPool commit
This commit is contained in:
parent
1b3f15fef3
commit
e5dd766dd5
2 changed files with 12 additions and 5 deletions
|
@ -171,17 +171,19 @@ function BackendCoinPayments($coin)
|
|||
if(!$user) continue;
|
||||
if(!isset($addresses[$user->username])) continue;
|
||||
|
||||
$payment_amount = bitcoinvaluetoa($addresses[$user->username]);
|
||||
|
||||
$payout = new db_payouts;
|
||||
$payout->account_id = $user->id;
|
||||
$payout->time = time();
|
||||
$payout->amount = bitcoinvaluetoa($user->balance*$coef);
|
||||
$payout->amount = $payment_amount;
|
||||
$payout->fee = 0;
|
||||
$payout->idcoin = $coin->id;
|
||||
|
||||
if ($payout->save()) {
|
||||
$payouts[$payout->id] = $user->id;
|
||||
|
||||
$user->balance = bitcoinvaluetoa(floatval($user->balance) - (floatval($user->balance)*$coef));
|
||||
$user->balance = bitcoinvaluetoa(floatval($user->balance) - $payment_amount);
|
||||
$user->save();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -57,8 +57,10 @@ class CronjobController extends CommonController
|
|||
dborun("update jobs set active=false");
|
||||
|
||||
BackendBlockFind1();
|
||||
BackendClearEarnings();
|
||||
BackendRentingUpdate();
|
||||
if(!memcache_get($this->memcache->memcache, 'balances_locked')) {
|
||||
BackendClearEarnings();
|
||||
BackendRentingUpdate();
|
||||
}
|
||||
BackendProcessList();
|
||||
BackendBlocksUpdate();
|
||||
|
||||
|
@ -209,10 +211,13 @@ class CronjobController extends CommonController
|
|||
|
||||
sleep(10);
|
||||
BackendDoBackup();
|
||||
|
||||
memcache_set($this->memcache->memcache, 'apache_locked', false);
|
||||
|
||||
// prevent user balances changes during payments (blocks thread)
|
||||
memcache_set($this->memcache->memcache, 'balances_locked', true);
|
||||
BackendPayments();
|
||||
memcache_set($this->memcache->memcache, 'balances_locked', false);
|
||||
|
||||
BackendCleanDatabase();
|
||||
|
||||
// BackendOptimizeTables();
|
||||
|
|
Loading…
Add table
Reference in a new issue