[bisq-network/bisq] Reduce initial request size (#4233)

Florian Reimair notifications at github.com
Tue May 26 10:42:48 UTC 2020


@freimair commented on this pull request.



> @@ -205,24 +213,47 @@ public GetUpdatedDataRequest buildGetUpdatedDataRequest(NodeAddress senderNodeAd
         return new GetUpdatedDataRequest(senderNodeAddress, nonce, this.getKnownPayloadHashes());
     }
 
+    private byte[] getSpecialKey() {
+        byte[] result = new byte[20];
+        Arrays.fill(result, (byte) 0);
+        System.arraycopy(Version.VERSION.getBytes(), 0, result, 0, Version.VERSION.length());
+        return result;
+    }
+
+    private String containsSpecialKey(Set<P2PDataStorage.ByteArray> collection) {
+        Optional<String> result = collection.stream().map(byteArray -> new String(byteArray.bytes).trim()).filter(s -> s.matches("^[0-9]\\.[0-9]\\.[0-9]$")).findFirst();

Just played around with it a bit. Doing an old-fashioned for-switch-if routine is about 10 times faster. However, 10 times faster means it takes an average of 2,6ms vs. 23,4ms (60k objects, average over 100 tries) for an operation that is performed twice during the runtime of Bisq (file loading time is about 3 seconds). In contrast, it takes 20 LOC more to achieve this. 

ad deterministic behavior: I haven't found any hint on non-deterministic behavior. Creating a String from byte[] is pretty standard. I, however, added a charset for good measure. Although "\d.\d.\d" contains nothing another charset would handle differently.

-- 
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/4233#discussion_r430319512
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.bisq.network/pipermail/bisq-github/attachments/20200526/180742eb/attachment-0001.html>


More information about the bisq-github mailing list