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

chimp1984 notifications at github.com
Wed Dec 11 18:36:22 UTC 2019


chimp1984 commented on this pull request.



> @@ -145,6 +154,10 @@ private DaoState(int chainHeight,
         this.paramChangeList = paramChangeList;
         this.evaluatedProposalList = evaluatedProposalList;
         this.decryptedBallotsWithMeritsList = decryptedBallotsWithMeritsList;
+
+        txMap = blocks.stream()
+                .flatMap(block -> block.getTxs().stream())
+                .collect(Collectors.toMap(Tx::getId, Function.identity(), (x, y) -> y, HashMap::new));

Yes, I expected that intention...

I just was wondering how we can be sure to not change behaviour. The previous code used the flatMap. 

```
 public Stream<Tx> getTxStream() {
        return getBlocks().stream()
                .flatMap(block -> block.getTxs().stream());
    }
```

Do you know how potential key conflics would have been handled there? i assume your mergeFunction to overwrite with a new value if it happens is likely the standad behaviour if not otherwise defined. So your mergeFunction is likely better than throwing an exception if flatMap behaves the same. Anyway a bit "esoteric" but the DAO might deserve a bit of extra paranoia ;-)

-- 
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_r356765289
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.bisq.network/pipermail/bisq-github/attachments/20191211/400d25e2/attachment.html>


More information about the bisq-github mailing list