mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2024-11-17 17:57:40 +00:00
untested extra bool mutex flag
This commit is contained in:
parent
8f0da21d2b
commit
25bc126cf9
1 changed files with 13 additions and 2 deletions
|
@ -91,6 +91,7 @@ class ElectrumX {
|
|||
StreamSubscription<TorConnectionStatusChangedEvent>? _torStatusListener;
|
||||
|
||||
final Mutex _torConnectingLock = Mutex();
|
||||
bool _requireMutex = false;
|
||||
|
||||
ElectrumX({
|
||||
required String host,
|
||||
|
@ -117,11 +118,13 @@ class ElectrumX {
|
|||
switch (event.newStatus) {
|
||||
case TorConnectionStatus.connecting:
|
||||
await _torConnectingLock.acquire();
|
||||
_requireMutex = true;
|
||||
break;
|
||||
|
||||
case TorConnectionStatus.connected:
|
||||
case TorConnectionStatus.disconnected:
|
||||
_torConnectingLock.release();
|
||||
_requireMutex = false;
|
||||
break;
|
||||
}
|
||||
},
|
||||
|
@ -260,7 +263,11 @@ class ElectrumX {
|
|||
throw WifiOnlyException();
|
||||
}
|
||||
|
||||
await _torConnectingLock.protect(() async => _checkRpcClient());
|
||||
if (_requireMutex) {
|
||||
await _torConnectingLock.protect(() async => _checkRpcClient());
|
||||
} else {
|
||||
_checkRpcClient();
|
||||
}
|
||||
|
||||
try {
|
||||
final requestId = requestID ?? const Uuid().v1();
|
||||
|
@ -346,7 +353,11 @@ class ElectrumX {
|
|||
throw WifiOnlyException();
|
||||
}
|
||||
|
||||
await _torConnectingLock.protect(() async => _checkRpcClient());
|
||||
if (_requireMutex) {
|
||||
await _torConnectingLock.protect(() async => _checkRpcClient());
|
||||
} else {
|
||||
_checkRpcClient();
|
||||
}
|
||||
|
||||
try {
|
||||
final List<String> requestStrings = [];
|
||||
|
|
Loading…
Reference in a new issue