mirror of https://github.com/m2049r/xmrwallet.git
dont update on every single block (#776)
This commit is contained in:
parent
d801a50962
commit
303b3aa354
|
@ -108,11 +108,15 @@ public class WalletService extends Service {
|
||||||
Timber.d("unconfirmedMoneyReceived() %d @ %s", amount, txId);
|
Timber.d("unconfirmedMoneyReceived() %d @ %s", amount, txId);
|
||||||
}
|
}
|
||||||
|
|
||||||
int lastTxCount = 0;
|
private long lastBlockTime = 0;
|
||||||
|
private int lastTxCount = 0;
|
||||||
|
|
||||||
public void newBlock(long height) {
|
public void newBlock(long height) {
|
||||||
final Wallet wallet = getWallet();
|
final Wallet wallet = getWallet();
|
||||||
if (wallet == null) throw new IllegalStateException("No wallet!");
|
if (wallet == null) throw new IllegalStateException("No wallet!");
|
||||||
|
// don't flood with an update for every block ...
|
||||||
|
if (lastBlockTime < System.currentTimeMillis() - 2000) {
|
||||||
|
lastBlockTime = System.currentTimeMillis();
|
||||||
Timber.d("newBlock() @ %d with observer %s", height, observer);
|
Timber.d("newBlock() @ %d with observer %s", height, observer);
|
||||||
if (observer != null) {
|
if (observer != null) {
|
||||||
boolean fullRefresh = false;
|
boolean fullRefresh = false;
|
||||||
|
@ -132,6 +136,7 @@ public class WalletService extends Service {
|
||||||
observer.onRefreshed(wallet, fullRefresh);
|
observer.onRefreshed(wallet, fullRefresh);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void updated() {
|
public void updated() {
|
||||||
Timber.d("updated()");
|
Timber.d("updated()");
|
||||||
|
|
Loading…
Reference in New Issue