use cached txs in xmr wallet service instead of querying wallet

This commit is contained in:
woodser 2024-04-19 13:17:42 -04:00
parent a107acbdb4
commit 8097b0f499
8 changed files with 36 additions and 22 deletions

View file

@ -171,7 +171,7 @@ public class TxIdTextField extends AnchorPane {
private synchronized void updateConfidence(String txId, boolean useCache, Long height) {
MoneroTx tx = null;
try {
tx = useCache ? xmrWalletService.getTxWithCache(txId) : xmrWalletService.getTx(txId);
tx = useCache ? xmrWalletService.getDaemonTxWithCache(txId) : xmrWalletService.getDaemonTx(txId);
tx.setNumConfirmations(tx.isConfirmed() ? (height == null ? xmrWalletService.getConnectionService().getLastInfo().getHeight() : height) - tx.getHeight(): 0l); // TODO: don't set if tx.getNumConfirmations() works reliably on non-local testnet
} catch (Exception e) {
// do nothing

View file

@ -50,7 +50,7 @@ class DisplayedTransactions extends ObservableListDecorator<TransactionsListItem
}
private List<TransactionsListItem> getTransactionListItems() {
List<MoneroTxWallet> transactions = xmrWalletService.getTransactions(false);
List<MoneroTxWallet> transactions = xmrWalletService.getTxs(false);
return transactions.stream()
.map(this::convertTransactionToListItem)
.collect(Collectors.toList());

View file

@ -171,7 +171,7 @@ public abstract class TradeStepView extends AnchorPane {
List<String> txIds = new ArrayList<String>();
if (!model.dataModel.makerTxId.isEmpty().get()) txIds.add(model.dataModel.makerTxId.get());
if (!model.dataModel.takerTxId.isEmpty().get()) txIds.add(model.dataModel.takerTxId.get());
new Thread(() -> trade.getXmrWalletService().getTxsWithCache(txIds)).start();
new Thread(() -> trade.getXmrWalletService().getDaemonTxsWithCache(txIds)).start();
}
public void activate() {

View file

@ -40,7 +40,7 @@ public class DisplayedTransactionsTest {
List<MoneroTxWallet> transactions = Lists.newArrayList(mock(MoneroTxWallet.class), mock(MoneroTxWallet.class));
XmrWalletService walletService = mock(XmrWalletService.class);
when(walletService.getTransactions(false)).thenReturn(transactions);
when(walletService.getTxs(false)).thenReturn(transactions);
TransactionListItemFactory transactionListItemFactory = mock(TransactionListItemFactory.class,
RETURNS_DEEP_STUBS);
@ -60,7 +60,7 @@ public class DisplayedTransactionsTest {
@Test
public void testUpdateWhenRepositoryIsEmpty() {
XmrWalletService walletService = mock(XmrWalletService.class);
when(walletService.getTransactions(false))
when(walletService.getTxs(false))
.thenReturn(Collections.singletonList(mock(MoneroTxWallet.class)));
TradableRepository tradableRepository = mock(TradableRepository.class);