mirror of
https://github.com/bisq-network/bisq.git
synced 2025-01-19 05:44:05 +01:00
Remove redundant listener from TransactionsListItem
Eliminate a minor quadratic time bug, caused by the unnecessary addition of a (BtcWalletService) TxConfidenceListener for each list item in the Transactions view. (Since the confidence listeners are internally held in a CopyOnWriteArraySet, this sadly runs in quadratic time, slowing down the Transactions view load a little.) The confidence listener is apparently redundant because of a set of calls to 'TransactionsListItem.cleanup' immediately upon construction of the item list, which removes all the listeners just added. (This code appears to date from at least February 2016, in commit c70df86.) (The confidence indicators are kept up to date by simply reloading the entire list upon each wallet change event.)
This commit is contained in:
parent
2e8f03061e
commit
ee45202521
@ -22,7 +22,6 @@ import bisq.desktop.util.DisplayUtils;
|
|||||||
import bisq.desktop.util.GUIUtil;
|
import bisq.desktop.util.GUIUtil;
|
||||||
import bisq.desktop.util.filtering.FilterableListItem;
|
import bisq.desktop.util.filtering.FilterableListItem;
|
||||||
|
|
||||||
import bisq.core.btc.listeners.TxConfidenceListener;
|
|
||||||
import bisq.core.btc.wallet.BsqWalletService;
|
import bisq.core.btc.wallet.BsqWalletService;
|
||||||
import bisq.core.btc.wallet.BtcWalletService;
|
import bisq.core.btc.wallet.BtcWalletService;
|
||||||
import bisq.core.btc.wallet.WalletService;
|
import bisq.core.btc.wallet.WalletService;
|
||||||
@ -59,7 +58,6 @@ import javax.annotation.Nullable;
|
|||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
class TransactionsListItem implements FilterableListItem {
|
class TransactionsListItem implements FilterableListItem {
|
||||||
private final BtcWalletService btcWalletService;
|
|
||||||
private final CoinFormatter formatter;
|
private final CoinFormatter formatter;
|
||||||
private String dateString;
|
private String dateString;
|
||||||
private final Date date;
|
private final Date date;
|
||||||
@ -69,7 +67,6 @@ class TransactionsListItem implements FilterableListItem {
|
|||||||
private String details = "";
|
private String details = "";
|
||||||
private String addressString = "";
|
private String addressString = "";
|
||||||
private String direction = "";
|
private String direction = "";
|
||||||
private TxConfidenceListener txConfidenceListener;
|
|
||||||
private boolean received;
|
private boolean received;
|
||||||
private Coin amountAsCoin = Coin.ZERO;
|
private Coin amountAsCoin = Coin.ZERO;
|
||||||
private String memo = "";
|
private String memo = "";
|
||||||
@ -91,7 +88,6 @@ class TransactionsListItem implements FilterableListItem {
|
|||||||
// used at exportCSV
|
// used at exportCSV
|
||||||
TransactionsListItem() {
|
TransactionsListItem() {
|
||||||
date = null;
|
date = null;
|
||||||
btcWalletService = null;
|
|
||||||
txId = null;
|
txId = null;
|
||||||
formatter = null;
|
formatter = null;
|
||||||
isDustAttackTx = false;
|
isDustAttackTx = false;
|
||||||
@ -105,7 +101,6 @@ class TransactionsListItem implements FilterableListItem {
|
|||||||
DaoFacade daoFacade,
|
DaoFacade daoFacade,
|
||||||
CoinFormatter formatter,
|
CoinFormatter formatter,
|
||||||
long ignoreDustThreshold) {
|
long ignoreDustThreshold) {
|
||||||
this.btcWalletService = btcWalletService;
|
|
||||||
this.formatter = formatter;
|
this.formatter = formatter;
|
||||||
this.memo = transaction.getMemo();
|
this.memo = transaction.getMemo();
|
||||||
|
|
||||||
@ -303,19 +298,6 @@ class TransactionsListItem implements FilterableListItem {
|
|||||||
GUIUtil.updateConfidence(confidence, tooltip, txConfidenceIndicator);
|
GUIUtil.updateConfidence(confidence, tooltip, txConfidenceIndicator);
|
||||||
confirmations = confidence.getDepthInBlocks();
|
confirmations = confidence.getDepthInBlocks();
|
||||||
}});
|
}});
|
||||||
|
|
||||||
txConfidenceListener = new TxConfidenceListener(txId) {
|
|
||||||
@Override
|
|
||||||
public void onTransactionConfidenceChanged(TransactionConfidence confidence) {
|
|
||||||
GUIUtil.updateConfidence(confidence, lazy().tooltip, lazy().txConfidenceIndicator);
|
|
||||||
confirmations = confidence.getDepthInBlocks();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
btcWalletService.addTxConfidenceListener(txConfidenceListener);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void cleanup() {
|
|
||||||
btcWalletService.removeTxConfidenceListener(txConfidenceListener);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -279,7 +279,6 @@ public class TransactionsView extends ActivatableView<VBox, Void> {
|
|||||||
protected void deactivate() {
|
protected void deactivate() {
|
||||||
filterBox.deactivate();
|
filterBox.deactivate();
|
||||||
sortedList.comparatorProperty().unbind();
|
sortedList.comparatorProperty().unbind();
|
||||||
observableList.forEach(TransactionsListItem::cleanup);
|
|
||||||
btcWalletService.removeChangeEventListener(walletChangeEventListener);
|
btcWalletService.removeChangeEventListener(walletChangeEventListener);
|
||||||
|
|
||||||
if (scene != null)
|
if (scene != null)
|
||||||
@ -328,7 +327,6 @@ public class TransactionsView extends ActivatableView<VBox, Void> {
|
|||||||
})
|
})
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
// are sorted by getRecentTransactions
|
// are sorted by getRecentTransactions
|
||||||
transactionsListItems.forEach(TransactionsListItem::cleanup);
|
|
||||||
observableList.setAll(transactionsListItems);
|
observableList.setAll(transactionsListItems);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user