fix mailbox bootstrap issue

This commit is contained in:
jmacxx 2021-03-02 13:42:34 -06:00 committed by Christoph Atteneder
parent c1d6ea93bb
commit 62e71e1ccb
No known key found for this signature in database
GPG Key ID: CD5DC1C529CDFD3B
2 changed files with 15 additions and 9 deletions

View File

@ -334,12 +334,14 @@ public class P2PService implements SetupListener, MessageListener, ConnectionLis
p2PDataStorage.onBootstrapped();
// We don't use a listener at mailboxMessageService as we require the correct
// order of execution. The mailboxMessageService must be called before.
mailboxMessageService.onBootstrapped();
// Once we have applied the state in the P2P domain we notify our listeners
p2pServiceListeners.forEach(listenerHandler);
// We don't use a listener at mailboxMessageService as we require the correct
// order of execution. The p2pServiceListeners must be called before.
mailboxMessageService.onBootstrapped();
mailboxMessageService.initAfterBootstrapped();
}
}

View File

@ -221,13 +221,18 @@ public class MailboxMessageService implements HashMapChangedListener, PersistedD
public void onBootstrapped() {
if (!isBootstrapped) {
isBootstrapped = true;
// Only now we start listening and processing. The p2PDataStorage is our cache for data we have received
// after the hidden service was ready.
addHashMapChangedListenerAndApply();
maybeRepublishMailBoxMessages();
}
}
// second stage starup for MailboxMessageService ... apply existing messages to their modules
public void initAfterBootstrapped() {
// Only now we start listening and processing. The p2PDataStorage is our cache for data we have received
// after the hidden service was ready.
addHashMapChangedListener();
onAdded(p2PDataStorage.getMap().values());
maybeRepublishMailBoxMessages();
}
public void sendEncryptedMailboxMessage(NodeAddress peer,
PubKeyRing peersPubKeyRing,
@ -374,9 +379,8 @@ public class MailboxMessageService implements HashMapChangedListener, PersistedD
// Private
///////////////////////////////////////////////////////////////////////////////////////////
private void addHashMapChangedListenerAndApply() {
private void addHashMapChangedListener() {
p2PDataStorage.addHashMapChangedListener(this);
onAdded(p2PDataStorage.getMap().values());
}
private void processSingleMailboxEntry(Collection<ProtectedMailboxStorageEntry> protectedMailboxStorageEntries) {