fuzeCount logic refactor

This commit is contained in:
julian 2023-10-18 16:12:33 -06:00
parent 8e3e1db3cd
commit 649dac33b3

View file

@ -128,6 +128,7 @@ mixin FusionWalletInterface {
// Fusion object. // Fusion object.
fusion.Fusion? _mainFusionObject; fusion.Fusion? _mainFusionObject;
bool _stopRequested = false; bool _stopRequested = false;
int _currentFuseCount = 0;
/// Initializes the FusionWalletInterface mixin. /// Initializes the FusionWalletInterface mixin.
/// ///
@ -456,17 +457,23 @@ mixin FusionWalletInterface {
}, },
); );
int fuzeCount = 0; // reset count and flag
_currentFuseCount = 0;
_stopRequested = false; _stopRequested = false;
while (!_stopRequested) { bool shouldFuzeAgain() {
if (fusionInfo.rounds > 0) { if (fusionInfo.rounds <= 0) {
if (fuzeCount >= fusionInfo.rounds) { // ignore count if continuous
_stopRequested = true; return !_stopRequested;
} } else {
// not continuous
// check to make sure we aren't doing more fusions than requested
return !_stopRequested && _currentFuseCount < fusionInfo.rounds;
} }
}
fuzeCount++; while (shouldFuzeAgain()) {
_currentFuseCount++;
// refresh wallet utxos // refresh wallet utxos
await _updateWalletUTXOS(); await _updateWalletUTXOS();