backend: avoid to clear earnings during payouts (#249)

+ simplify payment code based on RavenMinerPool commit
This commit is contained in:
Tanguy Pruvot 2018-03-24 07:59:52 +01:00
parent 1b3f15fef3
commit e5dd766dd5
2 changed files with 12 additions and 5 deletions

View file

@ -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();
}
}

View file

@ -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();