[bisq-network/bisq] Speed up deposit and transactions view loads (#5120)

Steven Barclay notifications at github.com
Fri Jan 29 19:36:20 CET 2021


@stejbac commented on this pull request.



> @@ -408,18 +430,15 @@ public TransactionConfidence getConfidenceForTxId(String txId) {
         return null;
     }
 
-    protected TransactionConfidence getTransactionConfidence(Transaction tx, Address address) {
-        List<TransactionConfidence> transactionConfidenceList = getOutputsWithConnectedOutputs(tx)
-                .stream()
-                .filter(WalletService::isOutputScriptConvertibleToAddress)
-                .filter(output -> address != null && address.equals(getAddressFromOutput(output)))
-                .map(o -> tx.getConfidence())
-                .collect(Collectors.toList());
-        return getMostRecentConfidence(transactionConfidenceList);
+    private TransactionConfidence getTransactionConfidence(Transaction tx, Address address) {
+        boolean matchesAddress = getOutputsWithConnectedOutputs(tx).stream()
+                .anyMatch(output -> address != null && address.equals(getAddressFromOutput(output)));
+
+        return matchesAddress ? getMostRecentConfidence(List.of(tx.getConfidence())) : null;

Yes, I wasn't completely sure of the intent of the original version and tried to preserve its behaviour, but it looks like it may have been broken. The original stream pipeline had the line:

> .map(o -> tx.getConfidence())

But `tx` is the underlying method parameter and so this just fed a repeating list of the same `TransactionConfidence` object into `getMostRecentConfidence`.

I think it may be fixed by restoring the original pipeline, but using the lines:

> .flatMap(o -> Stream.ofNullable(o.getParentTransaction()))
> .map(Transaction::getConfidence)

in place of the `o -> tx.getConfidence` mapping.

This would make the method return null if (there was no matching output and) none of the tx inputs with the given address has a connecting parent tx (though I'm not sure if the latter ever happens). I guess that would be the right behaviour.

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/bisq-network/bisq/pull/5120#discussion_r567016742
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.bisq.network/pipermail/bisq-github/attachments/20210129/2249ab82/attachment.htm>


More information about the bisq-github mailing list