mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2025-01-31 15:06:04 +00:00
electrum stream potential fix
This commit is contained in:
parent
ce9e605b9e
commit
3dbbffaf5c
1 changed files with 6 additions and 2 deletions
|
@ -261,6 +261,7 @@ abstract class ElectrumWalletBase
|
|||
void Function(FlutterErrorDetails)? _onError;
|
||||
Timer? _autoSaveTimer;
|
||||
static const int _autoSaveInterval = 30;
|
||||
StreamSubscription<dynamic>? _receiveStream;
|
||||
|
||||
Future<void> init() async {
|
||||
await walletAddresses.init();
|
||||
|
@ -312,7 +313,8 @@ abstract class ElectrumWalletBase
|
|||
isSingleScan: doSingleScan ?? false,
|
||||
));
|
||||
|
||||
await for (var message in receivePort) {
|
||||
_receiveStream?.cancel();
|
||||
_receiveStream = receivePort.listen((var message) async {
|
||||
if (message is Map<String, ElectrumTransactionInfo>) {
|
||||
for (final map in message.entries) {
|
||||
final txid = map.key;
|
||||
|
@ -378,7 +380,7 @@ abstract class ElectrumWalletBase
|
|||
syncStatus = message.syncStatus;
|
||||
await walletInfo.updateRestoreHeight(message.height);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void _updateSilentAddressRecord(BitcoinSilentPaymentsUnspent unspent) {
|
||||
|
@ -455,6 +457,7 @@ abstract class ElectrumWalletBase
|
|||
try {
|
||||
syncStatus = ConnectingSyncStatus();
|
||||
|
||||
await _receiveStream?.cancel();
|
||||
await electrumClient.close();
|
||||
|
||||
electrumClient.onConnectionStatusChange = _onConnectionStatusChange;
|
||||
|
@ -1141,6 +1144,7 @@ abstract class ElectrumWalletBase
|
|||
@override
|
||||
Future<void> close() async {
|
||||
try {
|
||||
await _receiveStream?.cancel();
|
||||
await electrumClient.close();
|
||||
} catch (_) {}
|
||||
_autoSaveTimer?.cancel();
|
||||
|
|
Loading…
Reference in a new issue