[bisq-network/bisq] Add transient tx map to DaoState to speed up getTx queries (#3773)

Julian Knutsen notifications at github.com
Wed Dec 11 01:09:21 UTC 2019


julianknutsen commented on this pull request.



>      }
 
     public Set<Tx> getTxs() {
-        return getTxStream().collect(Collectors.toSet());
+        return new HashSet<>(getTxMap().values());

These are the callers I found of `getTxStream()`. It seems like most/all of them can be satisfied by the cache, but you have been looking at it longer than me so I might be missing a use case.

```getTxs: size()
getInvalidTxs: size()
getIrregularTxs: size()
getTotalBurntFee: sum()
getTotalAmountOfInvalidatedBsq: sum()
getTotalAmountOfBurntBsq: sum()
getBurntFeeTxs: Set<Tx>
getTx: Optional<Tx>
getTxOutputStream: [boolean, Optional<TxOutput>, Set<TxOutput>

maybeExportToJson: <no idea if this needs to be ordered...>
```

My point at a high level was that if we are going to build a cache for something, we should just use it for everything. By keeping an interface and users for the old slow way, It just creates additional performance work in the future that could be avoided by doing something better now.

Adding javadocs as you change methods is also a great way to reduce the technical debt and help explain to future users the guarantees or any gotchas that you learned the hard way.

-- 
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/3773#discussion_r356359717
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.bisq.network/pipermail/bisq-github/attachments/20191210/366a2cfb/attachment.html>


More information about the bisq-github mailing list