mirror of
https://github.com/Such-Software/hash-wallet.git
synced 2026-10-17 05:41:29 +02:00
fix: wallet not reporting finishing sync (#2377)
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:cw_core/utils/print_verbose.dart';
|
||||
import 'package:cw_monero/api/wallet.dart';
|
||||
import 'package:cw_monero/monero_account_list.dart';
|
||||
import 'package:monero/src/wallet2.dart';
|
||||
@@ -13,9 +14,13 @@ Wallet2WalletListener? _wlptr = null;
|
||||
|
||||
Wallet2WalletListener? getWlptr() {
|
||||
if (currentWallet == null) return null;
|
||||
_wlptrForW = currentWallet!.ffiAddress();
|
||||
_wlptr = currentWallet!.getWalletListener();
|
||||
return _wlptr!;
|
||||
if (_wlptrForW == currentWallet!.ffiAddress()) {
|
||||
return _wlptr;
|
||||
} else {
|
||||
_wlptrForW = currentWallet!.ffiAddress();
|
||||
_wlptr = currentWallet!.getWalletListener();
|
||||
return _wlptr;
|
||||
}
|
||||
}
|
||||
|
||||
Wallet2SubaddressAccount? subaddressAccount;
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import 'dart:async';
|
||||
import 'dart:ffi';
|
||||
import 'dart:isolate';
|
||||
import 'dart:math';
|
||||
|
||||
import 'package:cw_core/utils/print_verbose.dart';
|
||||
import 'package:cw_monero/api/account_list.dart';
|
||||
@@ -156,6 +157,9 @@ int cachedNodeHeight = 0;
|
||||
bool isHeightRefreshing = false;
|
||||
int getNodeHeightSync() {
|
||||
if (isHeightRefreshing == false) {
|
||||
if (cachedNodeHeight != 0 && getWlptr()?.height() == 1) {
|
||||
return cachedNodeHeight;
|
||||
}
|
||||
(() async {
|
||||
try {
|
||||
isHeightRefreshing = true;
|
||||
@@ -329,7 +333,13 @@ class SyncListener {
|
||||
_initialSyncHeight = syncHeight;
|
||||
}
|
||||
|
||||
final bchHeight = await getNodeHeightOrUpdate(syncHeight);
|
||||
// in case when node didn't report new height yet
|
||||
// it is a workaround for moving height request to another isolate
|
||||
final nodeHeight = await getNodeHeightOrUpdate(syncHeight);
|
||||
if (nodeHeight == 0) {
|
||||
return;
|
||||
}
|
||||
final bchHeight = max(nodeHeight, syncHeight);
|
||||
// printV("syncHeight: $syncHeight, _lastKnownBlockHeight: $_lastKnownBlockHeight, bchHeight: $bchHeight");
|
||||
if (_lastKnownBlockHeight == syncHeight) {
|
||||
return;
|
||||
@@ -341,7 +351,8 @@ class SyncListener {
|
||||
final ptc = diff <= 0 ? 0.0 : diff / track;
|
||||
final left = bchHeight - syncHeight;
|
||||
|
||||
if (syncHeight < 0 || left < 0) {
|
||||
if ((syncHeight < 0 || left < 0)) {
|
||||
printV("not calling onNewBlock: syncHeight: $syncHeight, left: $left");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user