Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix mailbox bootstrap issue #5267

Merged
merged 1 commit into from Mar 3, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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