mirror of
https://github.com/haveno-dex/haveno.git
synced 2024-12-26 07:49:31 -05:00
invoke main wallet listeners in thread pool
This commit is contained in:
parent
52a44d020e
commit
c14f37b595
@ -1315,18 +1315,19 @@ public class XmrWalletService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void updateBalanceListeners() {
|
public void updateBalanceListeners() {
|
||||||
|
BigInteger availableBalance = getAvailableBalance();
|
||||||
for (XmrBalanceListener balanceListener : balanceListeners) {
|
for (XmrBalanceListener balanceListener : balanceListeners) {
|
||||||
BigInteger balance;
|
BigInteger balance;
|
||||||
if (balanceListener.getSubaddressIndex() != null && balanceListener.getSubaddressIndex() != 0) balance = getBalanceForSubaddress(balanceListener.getSubaddressIndex());
|
if (balanceListener.getSubaddressIndex() != null && balanceListener.getSubaddressIndex() != 0) balance = getBalanceForSubaddress(balanceListener.getSubaddressIndex());
|
||||||
else balance = getAvailableBalance();
|
else balance = availableBalance;
|
||||||
ThreadUtils.execute(() -> {
|
ThreadUtils.submitToPool(() -> {
|
||||||
try {
|
try {
|
||||||
balanceListener.onBalanceChanged(balance);
|
balanceListener.onBalanceChanged(balance);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.warn("Failed to notify balance listener of change");
|
log.warn("Failed to notify balance listener of change");
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}, THREAD_ID);
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1370,39 +1371,31 @@ public class XmrWalletService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSyncProgress(long height, long startHeight, long endHeight, double percentDone, String message) {
|
public void onSyncProgress(long height, long startHeight, long endHeight, double percentDone, String message) {
|
||||||
ThreadUtils.execute(() -> {
|
for (MoneroWalletListenerI listener : walletListeners) ThreadUtils.submitToPool(() -> listener.onSyncProgress(height, startHeight, endHeight, percentDone, message));
|
||||||
for (MoneroWalletListenerI listener : walletListeners) listener.onSyncProgress(height, startHeight, endHeight, percentDone, message);
|
|
||||||
}, THREAD_ID);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onNewBlock(long height) {
|
public void onNewBlock(long height) {
|
||||||
ThreadUtils.execute(() -> {
|
UserThread.execute(() -> {
|
||||||
walletHeight.set(height);
|
walletHeight.set(height);
|
||||||
for (MoneroWalletListenerI listener : walletListeners) listener.onNewBlock(height);
|
for (MoneroWalletListenerI listener : walletListeners) ThreadUtils.submitToPool(() -> listener.onNewBlock(height));
|
||||||
}, THREAD_ID);
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onBalancesChanged(BigInteger newBalance, BigInteger newUnlockedBalance) {
|
public void onBalancesChanged(BigInteger newBalance, BigInteger newUnlockedBalance) {
|
||||||
ThreadUtils.execute(() -> {
|
|
||||||
for (MoneroWalletListenerI listener : walletListeners) listener.onBalancesChanged(newBalance, newUnlockedBalance);
|
|
||||||
updateBalanceListeners();
|
updateBalanceListeners();
|
||||||
}, THREAD_ID);
|
for (MoneroWalletListenerI listener : walletListeners) ThreadUtils.submitToPool(() -> listener.onBalancesChanged(newBalance, newUnlockedBalance));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onOutputReceived(MoneroOutputWallet output) {
|
public void onOutputReceived(MoneroOutputWallet output) {
|
||||||
ThreadUtils.execute(() -> {
|
for (MoneroWalletListenerI listener : walletListeners) ThreadUtils.submitToPool(() -> listener.onOutputReceived(output));
|
||||||
for (MoneroWalletListenerI listener : walletListeners) listener.onOutputReceived(output);
|
|
||||||
}, THREAD_ID);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onOutputSpent(MoneroOutputWallet output) {
|
public void onOutputSpent(MoneroOutputWallet output) {
|
||||||
ThreadUtils.execute(() -> {
|
for (MoneroWalletListenerI listener : walletListeners) ThreadUtils.submitToPool(() -> listener.onOutputSpent(output));
|
||||||
for (MoneroWalletListenerI listener : walletListeners) listener.onOutputSpent(output);
|
|
||||||
}, THREAD_ID);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user