[bisq-network/bisq] (7/8) Develop APIs for ProtectedStorageEntry to enable testing and code refactoring (#3583)

Florian Reimair notifications at github.com
Fri Nov 15 16:11:01 UTC 2019


freimair commented on this pull request.

you are correct, this will trigger some discussion. On the one hand, I really like how this clears up the code base, makes everything testable and more readable as well. On the other hand, you rely on an object to report on its own validity. From my side, I like the testing motivation so that is OK with me. We can always revisit this topic in the future.

please note the inline comment. Awaiting your response there.

> -        boolean result = storedData.getOwnerPubKey() != null && storedData.getOwnerPubKey().equals(ownerPubKey);
-        if (!result)
-            log.warn("New data entry does not match our stored data. storedData.ownerPubKey=" +
-                    (storedData.getOwnerPubKey() != null ? storedData.getOwnerPubKey().toString() : "null") +
-                    ", ownerPubKey=" + ownerPubKey);
-
-        return result;
-    }
-
-    private boolean checkIfStoredMailboxDataMatchesNewMailboxData(PublicKey receiversPubKey, ByteArray hashOfData) {
-        ProtectedStorageEntry storedData = map.get(hashOfData);
-        if (storedData instanceof ProtectedMailboxStorageEntry) {
-            ProtectedMailboxStorageEntry entry = (ProtectedMailboxStorageEntry) storedData;
-            // publicKey is not the same (stored: sender, new: receiver)
-            boolean result = entry.getReceiversPubKey().equals(receiversPubKey)
-                    && get32ByteHashAsByteArray(entry.getProtectedStoragePayload()).equals(hashOfData);

you did not migrate the hash calculation and comparison to the `ProtectedMailboxStorageEntry`. Can you elaborate?

-- 
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/3583#pullrequestreview-317716568
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.bisq.network/pipermail/bisq-github/attachments/20191115/d1df15a9/attachment-0001.html>


More information about the bisq-github mailing list