Skip to content

Commit a99f2ad

Browse files
committed
big performance optimization for transactions
1 parent ac493e9 commit a99f2ad

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

src/Services/CommonServiceLegacy.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -200,12 +200,8 @@ public function applyTransactions(array $wallets, array $objects): array
200200
$object = $this->castService->getWallet($wallet);
201201
assert((int) $object->getKey() === $walletId);
202202

203-
$object->getBalanceAttribute();
204-
$balance = $this->regulatorService->increase($object, $total);
203+
$this->regulatorService->increase($object, $total);
205204
$this->stateService->persist($object);
206-
207-
$object->newQuery()->whereKey($object->getKey())->update(['balance' => $balance]); // ?qN
208-
$object->fill(['balance' => $balance])->syncOriginalAttribute('balance');
209205
}
210206

211207
return $transactions;

src/Services/StateService.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,10 @@ public function commit(): void
4444
continue;
4545
}
4646

47-
$this->bookkeeperService->increase($wallet, $diffValue);
47+
$balance = $this->bookkeeperService->increase($wallet, $diffValue);
48+
$wallet->newQuery()->whereKey($wallet->getKey())->update(['balance' => $balance]); // ?qN
49+
$wallet->fill(['balance' => $balance])->syncOriginalAttribute('balance');
50+
4851
$flags[$wallet->uuid] = true;
4952
}
5053

0 commit comments

Comments
 (0)