mirror of
https://github.com/haveno-dex/haveno.git
synced 2025-08-14 09:25:37 -04:00
cache incoming txs to improve performance of funds tab
This commit is contained in:
parent
a21628ad0d
commit
1c6d4cec83
3 changed files with 18 additions and 9 deletions
|
@ -914,16 +914,21 @@ public class XmrWalletService {
|
|||
return getNumTxOutputsForSubaddress(subaddressIndex, null);
|
||||
}
|
||||
|
||||
private int getNumTxOutputsForSubaddress(int subaddressIndex, List<MoneroTxWallet> incomingTxs) {
|
||||
public int getNumTxOutputsForSubaddress(int subaddressIndex, List<MoneroTxWallet> incomingTxs) {
|
||||
if (incomingTxs == null) incomingTxs = getIncomingTxs(subaddressIndex);
|
||||
int numUnspentOutputs = 0;
|
||||
for (MoneroTxWallet tx : incomingTxs) {
|
||||
if (tx.getTransfers(new MoneroTransferQuery().setSubaddressIndex(subaddressIndex)).isEmpty()) continue;
|
||||
numUnspentOutputs += tx.isConfirmed() ? tx.getOutputsWallet(new MoneroOutputQuery().setSubaddressIndex(subaddressIndex)).size() : 1; // TODO: monero-project does not provide outputs for unconfirmed txs
|
||||
}
|
||||
return numUnspentOutputs;
|
||||
}
|
||||
|
||||
private List<MoneroTxWallet> getIncomingTxs(Integer subaddressIndex) {
|
||||
public List<MoneroTxWallet> getIncomingTxs() {
|
||||
return getIncomingTxs(null);
|
||||
}
|
||||
|
||||
public List<MoneroTxWallet> getIncomingTxs(Integer subaddressIndex) {
|
||||
return wallet.getTxs(new MoneroTxQuery()
|
||||
.setTransferQuery((new MoneroTransferQuery()
|
||||
.setAccountIndex(0)
|
||||
|
@ -970,7 +975,7 @@ public class XmrWalletService {
|
|||
|
||||
// TODO (woodser): update balance and other listening
|
||||
public void addBalanceListener(XmrBalanceListener listener) {
|
||||
balanceListeners.add(listener);
|
||||
if (!balanceListeners.contains(listener)) balanceListeners.add(listener);
|
||||
}
|
||||
|
||||
public void removeBalanceListener(XmrBalanceListener listener) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue