[bisq-network/bisq] Add transient tx map to DaoState to speed up getTx queries (#3773)
chimp1984
notifications at github.com
Wed Dec 11 19:03:09 UTC 2019
chimp1984 commented on this pull request.
> @@ -624,7 +625,8 @@ public int getNumIssuanceTransactions(IssuanceType issuanceType) {
return daoStateService.getUnspentTxOutputs();
}
- public Set<Tx> getTxs() {
+ // Returns a view rather than a copy of all the txs.
+ public Collection<Tx> getTxs() {
As the client only is interested in the number of txs, I think we should change that to a method only returning the size. This will further render the getTxs() method in daoStateService needless.
> }
- public Set<Tx> getTxs() {
- return new HashSet<>(getTxMap().values());
- }
-
- public Optional<Tx> getTx(String txId) {
- return Optional.ofNullable(getTxMap().get(txId));
+ public Collection<Tx> getTxs() {
This method is only called by DaoFacade where the client is only interested in the size, so I would suggest to add a new `getNumTxs()` method instead and the other usage is the `getUnorderedTxStream()` method in the same class, which could use `daoState.getTxMap().values().stream()` directly. So we can remove the `getTxs()` completely.
> @@ -115,6 +116,9 @@ public void applySnapshot(DaoState snapshot) {
daoState.setChainHeight(snapshot.getChainHeight());
+ daoState.getTxMap().clear();
+ daoState.getTxMap().putAll(snapshot.getTxMap());
I fear that might not have much effect on performance as usually there are very few txs in a block. In average we have 1 tx in 2 blocks.
--
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#pullrequestreview-330762871
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.bisq.network/pipermail/bisq-github/attachments/20191211/1a34b8e4/attachment.html>
More information about the bisq-github
mailing list