mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2024-11-16 09:17:35 +00:00
store() on bad network (#1543)
* fix: for storing on bad network connection. * feat from standup * fix missing declaration * remove forcing trusted daemon flag [skip ci] --------- Co-authored-by: OmarHatem <omarh.ismail1@gmail.com>
This commit is contained in:
parent
341e06196d
commit
7514d851ce
2 changed files with 29 additions and 2 deletions
|
@ -121,9 +121,23 @@ void setRecoveringFromSeed({required bool isRecovery}) =>
|
|||
monero.Wallet_setRecoveringFromSeed(wptr!, recoveringFromSeed: isRecovery);
|
||||
|
||||
final storeMutex = Mutex();
|
||||
|
||||
|
||||
int lastStorePointer = 0;
|
||||
int lastStoreHeight = 0;
|
||||
void storeSync() async {
|
||||
await storeMutex.acquire();
|
||||
final addr = wptr!.address;
|
||||
final synchronized = await Isolate.run(() {
|
||||
return monero.Wallet_synchronized(Pointer.fromAddress(addr));
|
||||
});
|
||||
if (lastStorePointer == wptr!.address &&
|
||||
lastStoreHeight + 5000 < monero.Wallet_blockChainHeight(wptr!) &&
|
||||
!synchronized) {
|
||||
return;
|
||||
}
|
||||
lastStorePointer = wptr!.address;
|
||||
lastStoreHeight = monero.Wallet_blockChainHeight(wptr!);
|
||||
await storeMutex.acquire();
|
||||
await Isolate.run(() {
|
||||
monero.Wallet_store(Pointer.fromAddress(addr));
|
||||
});
|
||||
|
|
|
@ -126,9 +126,22 @@ void setRecoveringFromSeed({required bool isRecovery}) =>
|
|||
wownero.Wallet_setRecoveringFromSeed(wptr!, recoveringFromSeed: isRecovery);
|
||||
|
||||
final storeMutex = Mutex();
|
||||
|
||||
int lastStorePointer = 0;
|
||||
int lastStoreHeight = 0;
|
||||
void storeSync() async {
|
||||
await storeMutex.acquire();
|
||||
final addr = wptr!.address;
|
||||
final synchronized = await Isolate.run(() {
|
||||
return wownero.Wallet_synchronized(Pointer.fromAddress(addr));
|
||||
});
|
||||
if (lastStorePointer == wptr!.address &&
|
||||
lastStoreHeight + 5000 < wownero.Wallet_blockChainHeight(wptr!) &&
|
||||
!synchronized) {
|
||||
return;
|
||||
}
|
||||
lastStorePointer = wptr!.address;
|
||||
lastStoreHeight = wownero.Wallet_blockChainHeight(wptr!);
|
||||
await storeMutex.acquire();
|
||||
Isolate.run(() {
|
||||
wownero.Wallet_store(Pointer.fromAddress(addr));
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue