mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2024-12-23 11:59:30 +00:00
check and update ui if xmr/wow data found during re/scan
This commit is contained in:
parent
66e9f87c0f
commit
b3ff38adb7
2 changed files with 86 additions and 0 deletions
|
@ -1119,6 +1119,7 @@ class MoneroWallet extends CoinServiceAPI {
|
||||||
print("=============================");
|
print("=============================");
|
||||||
print("New Block! :: $walletName");
|
print("New Block! :: $walletName");
|
||||||
print("=============================");
|
print("=============================");
|
||||||
|
_refreshTxDataHelper();
|
||||||
}
|
}
|
||||||
|
|
||||||
void onNewTransaction() {
|
void onNewTransaction() {
|
||||||
|
@ -1136,6 +1137,48 @@ class MoneroWallet extends CoinServiceAPI {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool _txRefreshLock = false;
|
||||||
|
int _lastCheckedHeight = -1;
|
||||||
|
int _txCount = 0;
|
||||||
|
|
||||||
|
Future<void> _refreshTxDataHelper() async {
|
||||||
|
if (_txRefreshLock) return;
|
||||||
|
_txRefreshLock = true;
|
||||||
|
|
||||||
|
final syncStatus = walletBase?.syncStatus;
|
||||||
|
|
||||||
|
if (syncStatus != null && syncStatus is SyncingSyncStatus) {
|
||||||
|
final int blocksLeft = syncStatus.blocksLeft;
|
||||||
|
final tenKChange = blocksLeft ~/ 10000;
|
||||||
|
|
||||||
|
// only refresh transactions periodically during a sync
|
||||||
|
if (_lastCheckedHeight == -1 || tenKChange < _lastCheckedHeight) {
|
||||||
|
_lastCheckedHeight = tenKChange;
|
||||||
|
await _refreshTxData();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
await _refreshTxData();
|
||||||
|
}
|
||||||
|
|
||||||
|
_txRefreshLock = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> _refreshTxData() async {
|
||||||
|
final txnData = await _fetchTransactionData();
|
||||||
|
final count = txnData.getAllTransactions().length;
|
||||||
|
|
||||||
|
if (count > _txCount) {
|
||||||
|
_txCount = count;
|
||||||
|
_transactionData = Future(() => txnData);
|
||||||
|
GlobalEventBus.instance.fire(
|
||||||
|
UpdatedInBackgroundEvent(
|
||||||
|
"New transaction data found in $walletId $walletName!",
|
||||||
|
walletId,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void syncStatusChanged() async {
|
void syncStatusChanged() async {
|
||||||
final syncStatus = walletBase?.syncStatus;
|
final syncStatus = walletBase?.syncStatus;
|
||||||
if (syncStatus != null) {
|
if (syncStatus != null) {
|
||||||
|
|
|
@ -1163,6 +1163,49 @@ class WowneroWallet extends CoinServiceAPI {
|
||||||
print("=============================");
|
print("=============================");
|
||||||
print("New Wownero Block! :: $walletName");
|
print("New Wownero Block! :: $walletName");
|
||||||
print("=============================");
|
print("=============================");
|
||||||
|
_refreshTxDataHelper();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool _txRefreshLock = false;
|
||||||
|
int _lastCheckedHeight = -1;
|
||||||
|
int _txCount = 0;
|
||||||
|
|
||||||
|
Future<void> _refreshTxDataHelper() async {
|
||||||
|
if (_txRefreshLock) return;
|
||||||
|
_txRefreshLock = true;
|
||||||
|
|
||||||
|
final syncStatus = walletBase?.syncStatus;
|
||||||
|
|
||||||
|
if (syncStatus != null && syncStatus is SyncingSyncStatus) {
|
||||||
|
final int blocksLeft = syncStatus.blocksLeft;
|
||||||
|
final tenKChange = blocksLeft ~/ 10000;
|
||||||
|
|
||||||
|
// only refresh transactions periodically during a sync
|
||||||
|
if (_lastCheckedHeight == -1 || tenKChange < _lastCheckedHeight) {
|
||||||
|
_lastCheckedHeight = tenKChange;
|
||||||
|
await _refreshTxData();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
await _refreshTxData();
|
||||||
|
}
|
||||||
|
|
||||||
|
_txRefreshLock = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> _refreshTxData() async {
|
||||||
|
final txnData = await _fetchTransactionData();
|
||||||
|
final count = txnData.getAllTransactions().length;
|
||||||
|
|
||||||
|
if (count > _txCount) {
|
||||||
|
_txCount = count;
|
||||||
|
_transactionData = Future(() => txnData);
|
||||||
|
GlobalEventBus.instance.fire(
|
||||||
|
UpdatedInBackgroundEvent(
|
||||||
|
"New transaction data found in $walletId $walletName!",
|
||||||
|
walletId,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void onNewTransaction() {
|
void onNewTransaction() {
|
||||||
|
|
Loading…
Reference in a new issue