[bisq-network/bisq] Add rpc method 'getfundingaddresses' (#4299)

dmos62 notifications at github.com
Tue Jun 16 14:46:20 UTC 2020


@dmos62 requested changes on this pull request.



> +
+        // Iterate the list of Tuple3<AddressString, Balance, NumConfirmations> objects
+        // and build the formatted info string.
+        StringBuilder addressInfoBuilder = new StringBuilder();
+        addrBalanceConfirms.forEach(a -> {
+            var btcBalance = formatSatoshis.apply(a.second);
+            var numConfirmations = getNumConfirmationsForMostRecentTransaction(a.first);
+            String addressInfo = "" + a.first
+                    + "  balance: " + format("%13s", btcBalance)
+                    + ((a.second > 0) ? ("  confirmations: " + format("%6d", numConfirmations)) : "")
+                    + "\n";
+            addressInfoBuilder.append(addressInfo);
+        });
+
+        return addressInfoBuilder.toString().trim();
+    }

The Tuple3 feels unnecessary. Its main use seems to be to cache the balances, which are needed for checking if we need to generate a new address, otherwise we could get all that while formatting and a structure to hold these intermediary results wouldn't be necessary. Since the problem is basically caching, we can just do that explicitly by memoizing `getAddressBalance`:
```
var balances = CacheLoader.from(getAddressBalance);
// Usage:
var someBalance = balances.load(someAddress);
```
https://guava.dev/releases/20.0/api/docs/com/google/common/cache/CacheLoader.html

That will make the rest of the method simpler and shorter.

-- 
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/4299#pullrequestreview-431434133
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.bisq.network/pipermail/bisq-github/attachments/20200616/d7b33200/attachment.html>


More information about the bisq-github mailing list