Skip to content

Commit

Permalink
fix mailbox bootstrap issue
Browse files Browse the repository at this point in the history
  • Loading branch information
jmacxx authored and ripcurlx committed Mar 3, 2021
1 parent c1d6ea9 commit 62e71e1
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
8 changes: 5 additions & 3 deletions p2p/src/main/java/bisq/network/p2p/P2PService.java
Original file line number Diff line number Diff line change
Expand Up @@ -334,12 +334,14 @@ private void applyIsBootstrapped(Consumer<P2PServiceListener> listenerHandler) {

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();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -221,13 +221,18 @@ public void readPersisted(Runnable completeHandler) {
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,
Expand Down Expand Up @@ -374,9 +379,8 @@ public void onRemoved(Collection<ProtectedStorageEntry> protectedStorageEntries)
// Private
///////////////////////////////////////////////////////////////////////////////////////////

private void addHashMapChangedListenerAndApply() {
private void addHashMapChangedListener() {
p2PDataStorage.addHashMapChangedListener(this);
onAdded(p2PDataStorage.getMap().values());
}

private void processSingleMailboxEntry(Collection<ProtectedMailboxStorageEntry> protectedMailboxStorageEntries) {
Expand Down

0 comments on commit 62e71e1

Please sign in to comment.