Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
75 changes: 32 additions & 43 deletions lib/wallets/wallet/intermediate/lib_monero_wallet.dart
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,10 @@ abstract class LibMoneroWallet<T extends CryptonoteCurrency>

highestPercentCached = 0;
await csMonero.rescanBlockchain(wallet!);
// Reset again once the worker has accepted the rescan. A progress
// reading from before it can land in between and pin the guard near
// 100%, which hides every later reading until the rescan passes it.
highestPercentCached = 0;
await csMonero.startSyncing(wallet!);
unawaited(save());
});
Expand Down Expand Up @@ -881,10 +885,6 @@ abstract class LibMoneroWallet<T extends CryptonoteCurrency>
final _syncStatus = syncStatus;

if (_syncStatus != null) {
if (_syncStatus.progress() == 1 && refreshMutex.isLocked) {
refreshMutex.release();
}

WalletSyncStatus? status;
xmrAndWowSyncSpecificFunctionThatShouldBeGottenRidOfInTheFuture(true);

Expand Down Expand Up @@ -1119,51 +1119,40 @@ abstract class LibMoneroWallet<T extends CryptonoteCurrency>
Logging.instance.t(
"$runtimeType refresh() refreshMutex.acquire() waiting...",
);
await refreshMutex.acquire();
Logging.instance.t(
"$runtimeType refresh() refreshMutex.acquire() acquired!",
);

Logging.instance.t("$runtimeType refresh() final node = getCurrentNode();");
final node = getCurrentNode();

Logging.instance.i(
"$runtimeType refresh() await _torNodeMismatchGuard(node)",
);
if (await _torNodeMismatchGuard(node)) {
throw Exception("TOR – clearnet mismatch");
}
await refreshMutex.protect(() async {
Logging.instance.t(
"$runtimeType refresh() final node = getCurrentNode();",
);
final node = getCurrentNode();

Logging.instance.t(
"$runtimeType refresh() it csMonero.startSyncing(wallet!);",
);
await csMonero.startSyncing(wallet!);
Logging.instance.t(
"$runtimeType refresh() _setSyncStatus(lib_monero_compat.StartingSyncStatus());",
);
_setSyncStatus(lib_monero_compat.StartingSyncStatus());
Logging.instance.i(
"$runtimeType refresh() await _torNodeMismatchGuard(node)",
);
if (await _torNodeMismatchGuard(node)) {
throw Exception("TOR – clearnet mismatch");
}

Logging.instance.t("$runtimeType refresh() await updateTransactions();");
await updateTransactions();
Logging.instance.t("$runtimeType refresh() await updateBalance();");
await updateBalance();
Logging.instance.t(
"$runtimeType refresh() it csMonero.startSyncing(wallet!);",
);
await csMonero.startSyncing(wallet!);
Logging.instance.t(
"$runtimeType refresh() _setSyncStatus(lib_monero_compat.StartingSyncStatus());",
);
_setSyncStatus(lib_monero_compat.StartingSyncStatus());

Logging.instance.t(
"$runtimeType refresh() await checkReceivingAddressForTransactions();",
);
if (info.otherData[WalletInfoKeys.reuseAddress] != true) {
await checkReceivingAddressForTransactions();
}
Logging.instance.t("$runtimeType refresh() await updateTransactions();");
await updateTransactions();
Logging.instance.t("$runtimeType refresh() await updateBalance();");
await updateBalance();

Logging.instance.t(
"$runtimeType refresh() refreshMutex.isLocked=${refreshMutex.isLocked} pre release.",
);
if (refreshMutex.isLocked) {
refreshMutex.release();
Logging.instance.t(
"$runtimeType refresh() refreshMutex.isLocked manually released.",
"$runtimeType refresh() await checkReceivingAddressForTransactions();",
);
}
if (info.otherData[WalletInfoKeys.reuseAddress] != true) {
await checkReceivingAddressForTransactions();
}
});

Logging.instance.t(
"$runtimeType refresh() wallet != null && await csMonero.isSynced(wallet!)",
Expand Down
26 changes: 9 additions & 17 deletions lib/wallets/wallet/intermediate/lib_salvium_wallet.dart
Original file line number Diff line number Diff line change
Expand Up @@ -862,10 +862,6 @@ abstract class LibSalviumWallet<T extends CryptonoteCurrency>
final _syncStatus = syncStatus;

if (_syncStatus != null) {
if (_syncStatus.progress() == 1 && refreshMutex.isLocked) {
refreshMutex.release();
}

WalletSyncStatus? status;
xmrAndWowSyncSpecificFunctionThatShouldBeGottenRidOfInTheFuture(true);

Expand Down Expand Up @@ -1099,21 +1095,17 @@ abstract class LibSalviumWallet<T extends CryptonoteCurrency>

// this acquire should be almost instant due to above check.
// Slight possibility of race but should be irrelevant
await refreshMutex.acquire();

csSalvium.startSyncing(wallet!);
_setSyncStatus(StartingSyncStatus());

await updateTransactions();
await updateBalance();
await refreshMutex.protect(() async {
csSalvium.startSyncing(wallet!);
_setSyncStatus(StartingSyncStatus());

if (info.otherData[WalletInfoKeys.reuseAddress] != true) {
await checkReceivingAddressForTransactions();
}
await updateTransactions();
await updateBalance();

if (refreshMutex.isLocked) {
refreshMutex.release();
}
if (info.otherData[WalletInfoKeys.reuseAddress] != true) {
await checkReceivingAddressForTransactions();
}
});

final synced = wallet != null && await csSalvium.isSynced(wallet!);

Expand Down
26 changes: 9 additions & 17 deletions lib/wallets/wallet/intermediate/lib_wownero_wallet.dart
Original file line number Diff line number Diff line change
Expand Up @@ -898,10 +898,6 @@ abstract class LibWowneroWallet<T extends CryptonoteCurrency>
final _syncStatus = syncStatus;

if (_syncStatus != null) {
if (_syncStatus.progress() == 1 && refreshMutex.isLocked) {
refreshMutex.release();
}

WalletSyncStatus? status;
xmrAndWowSyncSpecificFunctionThatShouldBeGottenRidOfInTheFuture(true);

Expand Down Expand Up @@ -1136,21 +1132,17 @@ abstract class LibWowneroWallet<T extends CryptonoteCurrency>

// this acquire should be almost instant due to above check.
// Slight possibility of race but should be irrelevant
await refreshMutex.acquire();

csWownero.startSyncing(wallet!);
_setSyncStatus(lib_monero_compat.StartingSyncStatus());

await updateTransactions();
await updateBalance();
await refreshMutex.protect(() async {
csWownero.startSyncing(wallet!);
_setSyncStatus(lib_monero_compat.StartingSyncStatus());

if (info.otherData[WalletInfoKeys.reuseAddress] != true) {
await checkReceivingAddressForTransactions();
}
await updateTransactions();
await updateBalance();

if (refreshMutex.isLocked) {
refreshMutex.release();
}
if (info.otherData[WalletInfoKeys.reuseAddress] != true) {
await checkReceivingAddressForTransactions();
}
});

final synced = wallet != null && await csWownero.isSynced(wallet!);

Expand Down
Loading