[bisq-network/bisq] Add transient tx map to DaoState to speed up getTx queries (#3773)
Steven Barclay
notifications at github.com
Wed Dec 11 20:47:09 UTC 2019
stejbac 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));
With the `(x, y) -> y` merge function it's currently using, it will always select the last tx with a given txId from the tx stream when building the map, whereas in the original code `getTx` is calling `findAny` on the filtered `getTxStream` output, which will probably behave the same as `findFirst` in this case. So perhaps the merge function should be `(x, y) -> x` to be absolutely sure the behaviour doesn't change.
Also, for consistent merge behaviour, `putIfAbsent` would need to be substituted into the line:
> `daoState.getTxMap().put(tx.getId(), tx);`
in `DaoState.onNewTxForLastBlock`.
--
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_r356825145
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.bisq.network/pipermail/bisq-github/attachments/20191211/f7a307a0/attachment.html>
More information about the bisq-github
mailing list