Minor cleanup

This commit is contained in:
Konstantin Ullrich 2024-11-07 12:21:02 +01:00
parent 752b6bbebf
commit 86a3b6d65d
No known key found for this signature in database
GPG key ID: 6B3199AD9B3D23B8
2 changed files with 24 additions and 28 deletions

View file

@ -582,6 +582,8 @@ abstract class ElectrumWalletBase extends WalletBase<
Future<void> connectToNode({required Node node}) async {
this.node = node;
// if (syncStatus is ConnectingSyncStatus || syn) return;
try {
syncStatus = ConnectingSyncStatus();
@ -2090,7 +2092,7 @@ abstract class ElectrumWalletBase extends WalletBase<
});
}
final balances = await Future.wait(balanceFutures);
final balances = await Future.wait(balanceFutures); // ToDo: add onError ignore failed balances
for (var i = 0; i < balances.length; i++) {
final addressRecord = addresses[i];
@ -2229,13 +2231,14 @@ abstract class ElectrumWalletBase extends WalletBase<
if (syncStatus is NotConnectedSyncStatus ||
syncStatus is LostConnectionSyncStatus ||
syncStatus is ConnectingSyncStatus) {
syncStatus = AttemptingSyncStatus();
startSync();
syncStatus = ConnectedSyncStatus();
}
break;
case ConnectionStatus.disconnected:
if (syncStatus is! NotConnectedSyncStatus) {
if (syncStatus is! NotConnectedSyncStatus &&
syncStatus is! ConnectingSyncStatus &&
syncStatus is! SyncronizingSyncStatus) {
syncStatus = NotConnectedSyncStatus();
}
break;
@ -2292,10 +2295,8 @@ abstract class ElectrumWalletBase extends WalletBase<
void _updateInputsAndOutputs(ElectrumTransactionInfo tx, ElectrumTransactionBundle bundle) {
tx.inputAddresses = tx.inputAddresses?.where((address) => address.isNotEmpty).toList();
if (tx.inputAddresses == null ||
tx.inputAddresses!.isEmpty ||
tx.outputAddresses == null ||
tx.outputAddresses!.isEmpty) {
if (tx.inputAddresses?.isNotEmpty != true ||
tx.outputAddresses?.isNotEmpty != true) {
List<String> inputAddresses = [];
List<String> outputAddresses = [];

View file

@ -1,13 +1,5 @@
abstract class SyncStatus {
const SyncStatus();
double progress();
}
class StartingScanSyncStatus extends SyncStatus {
StartingScanSyncStatus(this.beginHeight);
final int beginHeight;
@override
double progress() => 0.0;
}
@ -39,16 +31,25 @@ class SyncedSyncStatus extends SyncStatus {
double progress() => 1.0;
}
/// ===========================================================================
abstract class ScanSyncStatus extends SyncStatus {}
class StartingScanSyncStatus extends SyncStatus {
StartingScanSyncStatus(this.beginHeight);
final int beginHeight;
}
class SyncedTipSyncStatus extends SyncedSyncStatus {
SyncedTipSyncStatus(this.tip);
final int tip;
}
class SyncronizingSyncStatus extends SyncStatus {
@override
double progress() => 0.0;
}
/// ===========================================================================
class SyncronizingSyncStatus extends SyncStatus {}
class NotConnectedSyncStatus extends SyncStatus {
const NotConnectedSyncStatus();
@ -75,15 +76,9 @@ class FailedSyncStatus extends NotConnectedSyncStatus {
String toString() => error ?? super.toString();
}
class ConnectingSyncStatus extends SyncStatus {
@override
double progress() => 0.0;
}
class ConnectingSyncStatus extends SyncStatus {}
class ConnectedSyncStatus extends SyncStatus {
@override
double progress() => 0.0;
}
class ConnectedSyncStatus extends SyncStatus {}
class UnsupportedSyncStatus extends NotConnectedSyncStatus {}