Skip to content

Commit 8537c44

Browse files
committed
optimize refreshBalance
1 parent 60105a9 commit 8537c44

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/Services/WalletServiceLegacy.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,18 @@ final class WalletServiceLegacy
1717
private MathServiceInterface $mathService;
1818
private RegulatorServiceInterface $regulatorService;
1919
private AtomicServiceInterface $atomicService;
20+
private StateServiceInterface $stateService;
2021

2122
public function __construct(
2223
MathServiceInterface $mathService,
2324
RegulatorServiceInterface $regulatorService,
24-
AtomicServiceInterface $atomicService
25+
AtomicServiceInterface $atomicService,
26+
StateServiceInterface $stateService
2527
) {
2628
$this->mathService = $mathService;
2729
$this->regulatorService = $regulatorService;
2830
$this->atomicService = $atomicService;
31+
$this->stateService = $stateService;
2932
}
3033

3134
/**
@@ -46,9 +49,10 @@ public function refresh(WalletModel $wallet): bool
4649
return true;
4750
}
4851

49-
$wallet->balance = (string) $balance;
52+
$this->stateService->persist($wallet);
53+
$wallet->fill(['balance' => $balance])->syncOriginalAttribute('balance');
5054

51-
return $wallet->save() && $this->regulatorService->sync($wallet, $balance);
55+
return $this->regulatorService->sync($wallet, $balance);
5256
});
5357
}
5458
}

0 commit comments

Comments
 (0)