mirror of
https://github.com/Such-Software/hash-wallet.git
synced 2026-12-04 12:34:14 +01:00
CAKE-149
This commit is contained in:
@@ -95,7 +95,7 @@ abstract class MoneroWalletBase extends WalletBase<MoneroBalance> with Store {
|
||||
address = subaddress.address;
|
||||
_setListeners();
|
||||
await transactionHistory.update();
|
||||
|
||||
print('walletInfo.isRecovery ${walletInfo.isRecovery}');
|
||||
if (walletInfo.isRecovery) {
|
||||
monero_wallet.setRecoveringFromSeed(isRecovery: walletInfo.isRecovery);
|
||||
|
||||
@@ -233,8 +233,7 @@ abstract class MoneroWalletBase extends WalletBase<MoneroBalance> with Store {
|
||||
|
||||
void _setListeners() {
|
||||
_listener?.stop();
|
||||
_listener = monero_wallet.setListeners(
|
||||
_onNewBlock, _onNeedToRefresh, _onNewTransaction);
|
||||
_listener = monero_wallet.setListeners(_onNewBlock);
|
||||
_listener.start();
|
||||
}
|
||||
|
||||
@@ -293,43 +292,30 @@ abstract class MoneroWalletBase extends WalletBase<MoneroBalance> with Store {
|
||||
int _getUnlockedBalance() =>
|
||||
monero_wallet.getUnlockedBalance(accountIndex: account.id);
|
||||
|
||||
void _onNewBlock(int height, int blocksLeft, double ptc) =>
|
||||
syncStatus = SyncingSyncStatus(blocksLeft, ptc);
|
||||
int _lastAutosaveTimestamp = 0;
|
||||
final int _autosaveInterval = 60000;
|
||||
|
||||
Future _onNeedToRefresh() async {
|
||||
if (syncStatus is FailedSyncStatus) {
|
||||
Future<void> _autoSave() async {
|
||||
final nowTimestamp = DateTime.now().millisecondsSinceEpoch;
|
||||
final sum = _lastAutosaveTimestamp + _autosaveInterval;
|
||||
|
||||
if (_lastAutosaveTimestamp != 0 && sum < nowTimestamp) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (walletInfo.isRecovery) {
|
||||
_askForUpdateTransactionHistory();
|
||||
_askForUpdateBalance();
|
||||
}
|
||||
|
||||
final currentHeight = getCurrentHeight();
|
||||
final nodeHeight = monero_wallet.getNodeHeightSync();
|
||||
|
||||
if (nodeHeight - currentHeight < moneroBlockSize) {
|
||||
syncStatus = SyncedSyncStatus();
|
||||
|
||||
if (walletInfo.isRecovery) {
|
||||
await setAsRecovered();
|
||||
}
|
||||
}
|
||||
|
||||
// if (walletInfo.isRecovery &&
|
||||
// (nodeHeight - currentHeight < moneroBlockSize)) {
|
||||
// await setAsRecovered();
|
||||
// }
|
||||
|
||||
if (currentHeight - _cachedRefreshHeight > moneroBlockSize) {
|
||||
_cachedRefreshHeight = currentHeight;
|
||||
await save();
|
||||
}
|
||||
_lastAutosaveTimestamp = nowTimestamp + _autosaveInterval;
|
||||
await save();
|
||||
}
|
||||
|
||||
void _onNewTransaction() {
|
||||
_askForUpdateBalance();
|
||||
void _onNewBlock(int height, int blocksLeft, double ptc) async {
|
||||
_askForUpdateTransactionHistory();
|
||||
_askForUpdateBalance();
|
||||
|
||||
if (blocksLeft < moneroBlockSize) {
|
||||
syncStatus = SyncedSyncStatus();
|
||||
await _autoSave();
|
||||
} else {
|
||||
syncStatus = SyncingSyncStatus(blocksLeft, ptc);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user