[bisq-network/bisq] Cache results in account witness domain (#4953)
chimp1984
notifications at github.com
Thu Dec 17 01:42:57 CET 2020
@chimp1984 commented on this pull request.
> @@ -487,8 +509,18 @@ private boolean verifyDate(SignedWitness signedWitness, long childSignedWitnessD
///////////////////////////////////////////////////////////////////////////////////////////
@VisibleForTesting
- void addToMap(SignedWitness signedWitness) {
- signedWitnessMap.putIfAbsent(signedWitness.getHashAsByteArray(), signedWitness);
+ public void addToMap(SignedWitness signedWitness) {
+ P2PDataStorage.ByteArray hash = signedWitness.getHashAsByteArray();
+ signedWitnessMap.putIfAbsent(hash, signedWitness);
+
+ // We remove the entry with that hash in case we have cached it, so at the next getSignedWitnessSet
+ // call we use the updated signedWitnessMap to re-fill our cache.
+ getSignedWitnessSetCache.remove(new P2PDataStorage.ByteArray(signedWitness.getAccountAgeWitnessHash()));
+
+ // Not sure if that is needed as well, tests did succeed in both cases, but seems to be more safe to remove
+ // potential entries with hash as well. A removed item in getSignedWitnessSetCache carries no risk, though a
+ // remaining item would.
+ getSignedWitnessSetCache.remove(hash);
I have not looked closely but I took it from the getSignedWitnessSet methods where `signedWitness.getHashAsByteArray()` got compared with `new P2PDataStorage.ByteArray(signedWitness.getAccountAgeWitnessHash())`. Have not looked deeper into the domain if those 2 data are the same actually. If so, yes that second remove is pointless.
--
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/4953#discussion_r544726267
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.bisq.network/pipermail/bisq-github/attachments/20201216/8b8bf3c8/attachment-0001.htm>
More information about the bisq-github
mailing list