<p><b>@chimp1984</b> commented on this pull request.</p>

<hr>

<p>In <a href="https://github.com/bisq-network/bisq/pull/3773#discussion_r356820395">core/src/main/java/bisq/core/dao/state/DaoStateService.java</a>:</p>
<pre style='color:#555'>>      }
 
     public Set<Tx> getTxs() {
-        return getTxStream().collect(Collectors.toSet());
+        return new HashSet<>(getTxMap().values());
</pre>
<p>I looked to all usages as well:<br>
Here my comments:</p>
<p><code>getInvalidTxs</code><br>
Used in UI for numTxs and in a <code>Set</code> for the chart. As it's a <code>Set</code> order is irrelevant.</p>
<p><code>getIrregularTxs: size()</code><br>
Used in UI for numTxs -> order is irrelevant.</p>
<pre><code>getTotalBurntFee: sum()
getTotalAmountOfInvalidatedBsq: sum()
getTotalAmountOfBurntBsq: sum()
</code></pre>
<p>Order is irrelevant for sum().</p>
<p><code>getBurntFeeTxs: Set<Tx></code><br>
Used in UI for numTxs and in a <code>Set</code> for the chart. As it's a <code>Set</code> order is irrelevant.</p>
<p><code>getTx: Optional<Tx></code><br>
TxId is unique so order is irrelevant.</p>
<p><code>getTxOutputStream: [boolean, Optional<TxOutput>, Set<TxOutput></code><br>
Used in <code>existsTxOutput</code> and <code>getTxOutput</code>:<br>
Both use <code>txOutputKey</code>and as <code>txOutputKey</code> is unique tx order is irrelevant.</p>
<p><code>maybeExportToJson</code><br>
It dumps txs and txOutputs to disk using the txId and txOutputKey as file name. As both are unique, order is irrelevant.</p>
<p>I guess the explorer will love to get some performance improvement from that change as well ;-). Writing to disk at each new block will be probably a major performance iussue there (another "low hanging fruit" -;) ).</p>
<p>Also looked into all usages of <code>block.getTxs()</code> and I do not see any write beside the addition of a tx in <code>onNewTxForLastBlock</code>. Maybe a public method inside <code>Block</code> encapsulating the write operation and exposing the getTxs() as unmodifiable List would make the code more safe. The read access cannot be replaced by the txMap, but as the write for both data structures happen at only one place I think it is safe (we do not have multiple threads here).</p>
<p>All the other data objects are immutable, only with <code>Block</code> it was hard as during parsing we need to know the state of past transaction in the same block. So keeping that local as we do with txs would have duplicate lots of code in DoaStateService where we need to look up if for instance BSQ is already spent by a previous tx.</p>

<p style="font-size:small;-webkit-text-size-adjust:none;color:#666;">—<br />You are receiving this because you are subscribed to this thread.<br />Reply to this email directly, <a href="https://github.com/bisq-network/bisq/pull/3773?email_source=notifications&email_token=AJFFTNXBCVIVF4RMWQV7OELQYFFJHA5CNFSM4JZCA3Q2YY3PNVWWK3TUL52HS4DFWFIHK3DMKJSXC5LFON2FEZLWNFSXPKTDN5WW2ZLOORPWSZGOCO374FY#discussion_r356820395">view it on GitHub</a>, or <a href="https://github.com/notifications/unsubscribe-auth/AJFFTNU7PTMUFWSGFZOBEJ3QYFFJHANCNFSM4JZCA3QQ">unsubscribe</a>.<img src="https://github.com/notifications/beacon/AJFFTNSDQVM7E3MY6SOH7B3QYFFJHA5CNFSM4JZCA3Q2YY3PNVWWK3TUL52HS4DFWFIHK3DMKJSXC5LFON2FEZLWNFSXPKTDN5WW2ZLOORPWSZGOCO374FY.gif" height="1" width="1" alt="" /></p>
<script type="application/ld+json">[
{
"@context": "http://schema.org",
"@type": "EmailMessage",
"potentialAction": {
"@type": "ViewAction",
"target": "https://github.com/bisq-network/bisq/pull/3773?email_source=notifications\u0026email_token=AJFFTNXBCVIVF4RMWQV7OELQYFFJHA5CNFSM4JZCA3Q2YY3PNVWWK3TUL52HS4DFWFIHK3DMKJSXC5LFON2FEZLWNFSXPKTDN5WW2ZLOORPWSZGOCO374FY#discussion_r356820395",
"url": "https://github.com/bisq-network/bisq/pull/3773?email_source=notifications\u0026email_token=AJFFTNXBCVIVF4RMWQV7OELQYFFJHA5CNFSM4JZCA3Q2YY3PNVWWK3TUL52HS4DFWFIHK3DMKJSXC5LFON2FEZLWNFSXPKTDN5WW2ZLOORPWSZGOCO374FY#discussion_r356820395",
"name": "View Pull Request"
},
"description": "View this Pull Request on GitHub",
"publisher": {
"@type": "Organization",
"name": "GitHub",
"url": "https://github.com"
}
}
]</script>