mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2025-01-21 10:14:40 +00:00
[skip ci] wip
This commit is contained in:
parent
df70bb7a56
commit
a9f7dec112
3 changed files with 22 additions and 26 deletions
|
@ -81,8 +81,15 @@ Map<int, Map<int, Map<int, String>>> addressCache = {};
|
||||||
|
|
||||||
String getAddress({int accountIndex = 0, int addressIndex = 0}) {
|
String getAddress({int accountIndex = 0, int addressIndex = 0}) {
|
||||||
|
|
||||||
|
int count = 0;
|
||||||
|
|
||||||
while (monero.Wallet_numSubaddresses(wptr!, accountIndex: accountIndex) - 1 < addressIndex) {
|
while (monero.Wallet_numSubaddresses(wptr!, accountIndex: accountIndex) - 1 < addressIndex) {
|
||||||
|
printV("adding subaddress");
|
||||||
monero.Wallet_addSubaddress(wptr!, accountIndex: accountIndex);
|
monero.Wallet_addSubaddress(wptr!, accountIndex: accountIndex);
|
||||||
|
if (count > 50) {
|
||||||
|
throw Exception("Failed to add subaddress");
|
||||||
|
}
|
||||||
|
count++;
|
||||||
}
|
}
|
||||||
|
|
||||||
addressCache[wptr!.address] ??= {};
|
addressCache[wptr!.address] ??= {};
|
||||||
|
|
|
@ -162,8 +162,8 @@ abstract class MoneroWalletBase
|
||||||
bool isMainThread = Isolate.current.debugName == "main";
|
bool isMainThread = Isolate.current.debugName == "main";
|
||||||
printV("isMainThread: $isMainThread");
|
printV("isMainThread: $isMainThread");
|
||||||
|
|
||||||
// _autoSaveTimer =
|
_autoSaveTimer =
|
||||||
// Timer.periodic(Duration(seconds: _autoSaveInterval), (_) async => await save());
|
Timer.periodic(Duration(seconds: _autoSaveInterval), (_) async => await save());
|
||||||
|
|
||||||
// update transaction details after restore
|
// update transaction details after restore
|
||||||
walletAddresses.subaddressList.update(accountIndex: walletAddresses.account?.id ?? 0);
|
walletAddresses.subaddressList.update(accountIndex: walletAddresses.account?.id ?? 0);
|
||||||
|
@ -203,34 +203,21 @@ abstract class MoneroWalletBase
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<void> startSync({bool isBackgroundSync = false}) async {
|
Future<void> startSync({bool isBackgroundSync = false}) async {
|
||||||
// if (isBackgroundSync) {
|
|
||||||
// try {
|
|
||||||
// syncStatus = AttemptingSyncStatus();
|
|
||||||
// monero_wallet.startBackgroundSync();
|
|
||||||
// isBackgroundSyncing = true;
|
|
||||||
// _setListeners();
|
|
||||||
// _listener?.start();
|
|
||||||
// return;
|
|
||||||
// } catch (e) {
|
|
||||||
// isBackgroundSyncing = false;
|
|
||||||
// syncStatus = FailedSyncStatus();
|
|
||||||
// printV(e);
|
|
||||||
// rethrow;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
syncStatus = AttemptingSyncStatus();
|
syncStatus = AttemptingSyncStatus();
|
||||||
// monero_wallet.startRefresh();
|
if (isBackgroundSync) {
|
||||||
monero_wallet.setupBackgroundSync(
|
monero_wallet.setupBackgroundSync(
|
||||||
backgroundSyncType: 2,
|
backgroundSyncType: 2,
|
||||||
walletPassword: password,
|
walletPassword: password,
|
||||||
backgroundCachePassword: "testing-cache-password",
|
backgroundCachePassword: "testing-cache-password",
|
||||||
);
|
);
|
||||||
monero_wallet.startBackgroundSync();
|
monero_wallet.startBackgroundSync();
|
||||||
if (isBackgroundSync) {
|
|
||||||
isBackgroundSyncing = true;
|
isBackgroundSyncing = true;
|
||||||
|
} else {
|
||||||
|
monero_wallet.stopBackgroundSync(password);
|
||||||
|
isBackgroundSyncing = false;
|
||||||
}
|
}
|
||||||
|
monero_wallet.startRefresh();
|
||||||
_setListeners();
|
_setListeners();
|
||||||
_listener?.start();
|
_listener?.start();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
|
|
@ -146,11 +146,13 @@ Future<void> onStart(ServiceInstance service) async {
|
||||||
for (int i = 0; i < syncingWallets.length; i++) {
|
for (int i = 0; i < syncingWallets.length; i++) {
|
||||||
final wallet = syncingWallets[i];
|
final wallet = syncingWallets[i];
|
||||||
await wallet.stopSync(isBackgroundSync: true);
|
await wallet.stopSync(isBackgroundSync: true);
|
||||||
|
await wallet.close();
|
||||||
}
|
}
|
||||||
// stop all standby wallets (just in case):
|
// stop all standby wallets (just in case):
|
||||||
for (int i = 0; i < standbyWallets.length; i++) {
|
for (int i = 0; i < standbyWallets.length; i++) {
|
||||||
final wallet = standbyWallets[i];
|
final wallet = standbyWallets[i];
|
||||||
await wallet.stopSync(isBackgroundSync: true);
|
await wallet.stopSync(isBackgroundSync: true);
|
||||||
|
await wallet.close();
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
printV("error stopping sync: $e");
|
printV("error stopping sync: $e");
|
||||||
|
|
Loading…
Reference in a new issue