[bisq-network/bisq] Persist and republish mailbox messages (#5072)

sqrrm notifications at github.com
Tue Jan 12 16:17:43 CET 2021


@sqrrm commented on this pull request.

Would it make sense to have seednodes request all mailbox messages on startup and then republish the discrepancy between the response and their locally persisted messages?

That would reduce the amount of republishing for the price of only seednodes asking for all messages from the other seednodes on startup.

>          return new MailboxItem(ProtectedMailboxStorageEntry.fromProto(proto.getProtectedMailboxStorageEntry(),
                 networkProtoResolver),
-                DecryptedMessageWithPubKey.fromProto(proto.getDecryptedMessageWithPubKey(), networkProtoResolver));
+                decryptedMessageWithPubKey);
+    }
+
+    public boolean isMine() {
+        return decryptedMessageWithPubKey != null;
+    }
+
+    public String getUid() {
+        if (decryptedMessageWithPubKey != null) {
+            // We use uid from mailboxMessage in case its ours as we have the at removeMailboxMsg only the
+            // decryptedMessageWithPubKey available which contains the mailboxMessage.
+            MailboxMessage mailboxMessage = (MailboxMessage) checkNotNull(decryptedMessageWithPubKey).getNetworkEnvelope();

Why the need for `checkNotNull` when that's checked in the if already

> @@ -406,18 +404,25 @@ private MailboxItem decryptProtectedMailboxStorageEntry(ProtectedMailboxStorageE
             log.error(e.toString());
             e.getStackTrace();
         }
-        return null;
+        return new MailboxItem(protectedMailboxStorageEntry, null);

Unnecessary empty line

> +        this.persistenceManager = persistenceManager;
+
+        this.persistenceManager.initialize(removedPayloadsMap, PersistenceManager.Source.PRIVATE_LOW_PRIO);
+    }
+
+
+    ///////////////////////////////////////////////////////////////////////////////////////////
+    // PersistedDataHost
+    ///////////////////////////////////////////////////////////////////////////////////////////
+
+    @Override
+    public void readPersisted(Runnable completeHandler) {
+        long cutOffDate = System.currentTimeMillis() - MailboxStoragePayload.TTL;
+        persistenceManager.readPersisted(persisted -> {
+                    persisted.getDateByHashes().entrySet().stream()
+                            .filter(e -> e.getValue() < cutOffDate)

I don't think I understand the usage of this class. Here is looks like when the persisted removedPayloadsMap is read the hashes that are older than the cutoff date are stored, but that means some removed data will be lost.

-- 
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/5072#pullrequestreview-566252416
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.bisq.network/pipermail/bisq-github/attachments/20210112/ac18c50e/attachment.htm>


More information about the bisq-github mailing list