mirror of
https://github.com/bisq-network/bisq.git
synced 2025-03-03 18:56:59 +01:00
Merge pull request #6376 from jmacxx/fix_issue_6367
Fix loss of mailbox messages during SPV resync
This commit is contained in:
commit
e054083c1f
3 changed files with 33 additions and 10 deletions
|
@ -58,6 +58,7 @@ import bisq.core.trade.txproof.xmr.XmrTxProofService;
|
||||||
import bisq.core.user.User;
|
import bisq.core.user.User;
|
||||||
|
|
||||||
import bisq.network.p2p.P2PService;
|
import bisq.network.p2p.P2PService;
|
||||||
|
import bisq.network.p2p.mailbox.MailboxMessageService;
|
||||||
|
|
||||||
import bisq.common.ClockWatcher;
|
import bisq.common.ClockWatcher;
|
||||||
import bisq.common.persistence.PersistenceManager;
|
import bisq.common.persistence.PersistenceManager;
|
||||||
|
@ -115,6 +116,7 @@ public class DomainInitialisation {
|
||||||
private final TriggerPriceService triggerPriceService;
|
private final TriggerPriceService triggerPriceService;
|
||||||
private final MempoolService mempoolService;
|
private final MempoolService mempoolService;
|
||||||
private final OpenBsqSwapOfferService openBsqSwapOfferService;
|
private final OpenBsqSwapOfferService openBsqSwapOfferService;
|
||||||
|
private final MailboxMessageService mailboxMessageService;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public DomainInitialisation(ClockWatcher clockWatcher,
|
public DomainInitialisation(ClockWatcher clockWatcher,
|
||||||
|
@ -154,7 +156,8 @@ public class DomainInitialisation {
|
||||||
DaoStateSnapshotService daoStateSnapshotService,
|
DaoStateSnapshotService daoStateSnapshotService,
|
||||||
TriggerPriceService triggerPriceService,
|
TriggerPriceService triggerPriceService,
|
||||||
MempoolService mempoolService,
|
MempoolService mempoolService,
|
||||||
OpenBsqSwapOfferService openBsqSwapOfferService) {
|
OpenBsqSwapOfferService openBsqSwapOfferService,
|
||||||
|
MailboxMessageService mailboxMessageService) {
|
||||||
this.clockWatcher = clockWatcher;
|
this.clockWatcher = clockWatcher;
|
||||||
this.tradeLimits = tradeLimits;
|
this.tradeLimits = tradeLimits;
|
||||||
this.arbitrationManager = arbitrationManager;
|
this.arbitrationManager = arbitrationManager;
|
||||||
|
@ -193,6 +196,7 @@ public class DomainInitialisation {
|
||||||
this.triggerPriceService = triggerPriceService;
|
this.triggerPriceService = triggerPriceService;
|
||||||
this.mempoolService = mempoolService;
|
this.mempoolService = mempoolService;
|
||||||
this.openBsqSwapOfferService = openBsqSwapOfferService;
|
this.openBsqSwapOfferService = openBsqSwapOfferService;
|
||||||
|
this.mailboxMessageService = mailboxMessageService;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void initDomainServices(Consumer<String> rejectedTxErrorMessageHandler,
|
public void initDomainServices(Consumer<String> rejectedTxErrorMessageHandler,
|
||||||
|
@ -277,6 +281,8 @@ public class DomainInitialisation {
|
||||||
triggerPriceService.onAllServicesInitialized();
|
triggerPriceService.onAllServicesInitialized();
|
||||||
mempoolService.onAllServicesInitialized();
|
mempoolService.onAllServicesInitialized();
|
||||||
|
|
||||||
|
mailboxMessageService.onAllServicesInitialized();
|
||||||
|
|
||||||
if (revolutAccountsUpdateHandler != null) {
|
if (revolutAccountsUpdateHandler != null) {
|
||||||
revolutAccountsUpdateHandler.accept(user.getPaymentAccountsAsObservable().stream()
|
revolutAccountsUpdateHandler.accept(user.getPaymentAccountsAsObservable().stream()
|
||||||
.filter(paymentAccount -> paymentAccount instanceof RevolutAccount)
|
.filter(paymentAccount -> paymentAccount instanceof RevolutAccount)
|
||||||
|
|
|
@ -502,9 +502,11 @@ public class NetworkSettingsView extends ActivatableView<GridPane, Void> {
|
||||||
bitcoinNetworkListItems.setAll(walletsSetup.getPeerGroup().getConnectedPeers().stream()
|
bitcoinNetworkListItems.setAll(walletsSetup.getPeerGroup().getConnectedPeers().stream()
|
||||||
.map(BitcoinNetworkListItem::new)
|
.map(BitcoinNetworkListItem::new)
|
||||||
.collect(Collectors.toList()));
|
.collect(Collectors.toList()));
|
||||||
|
if (walletsSetup.connectedPeersProperty().get() != null) {
|
||||||
chainHeightTextField.textProperty().setValue(Res.get("settings.net.chainHeight",
|
chainHeightTextField.textProperty().setValue(Res.get("settings.net.chainHeight",
|
||||||
walletsSetup.chainHeightProperty().get(),
|
walletsSetup.chainHeightProperty().get(),
|
||||||
PeerGroup.getMostCommonChainHeight(walletsSetup.connectedPeersProperty().get())));
|
PeerGroup.getMostCommonChainHeight(walletsSetup.connectedPeersProperty().get())));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -130,6 +130,8 @@ public class MailboxMessageService implements HashMapChangedListener, PersistedD
|
||||||
private final Map<String, MailboxItem> mailboxItemsByUid = new HashMap<>();
|
private final Map<String, MailboxItem> mailboxItemsByUid = new HashMap<>();
|
||||||
|
|
||||||
private boolean isBootstrapped;
|
private boolean isBootstrapped;
|
||||||
|
private boolean allServicesInitialized;
|
||||||
|
private boolean initAfterBootstrapped;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public MailboxMessageService(NetworkNode networkNode,
|
public MailboxMessageService(NetworkNode networkNode,
|
||||||
|
@ -236,6 +238,12 @@ public class MailboxMessageService implements HashMapChangedListener, PersistedD
|
||||||
// API
|
// API
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
// We wait until all services are ready to avoid some edge cases as in https://github.com/bisq-network/bisq/issues/6367
|
||||||
|
public void onAllServicesInitialized() {
|
||||||
|
allServicesInitialized = true;
|
||||||
|
init();
|
||||||
|
}
|
||||||
|
|
||||||
// We don't listen on requestDataManager directly as we require the correct
|
// We don't listen on requestDataManager directly as we require the correct
|
||||||
// order of execution. The p2pService is handling the correct order of execution and we get called
|
// order of execution. The p2pService is handling the correct order of execution and we get called
|
||||||
// directly from there.
|
// directly from there.
|
||||||
|
@ -247,12 +255,19 @@ public class MailboxMessageService implements HashMapChangedListener, PersistedD
|
||||||
|
|
||||||
// second stage starup for MailboxMessageService ... apply existing messages to their modules
|
// second stage starup for MailboxMessageService ... apply existing messages to their modules
|
||||||
public void initAfterBootstrapped() {
|
public void initAfterBootstrapped() {
|
||||||
|
initAfterBootstrapped = true;
|
||||||
|
init();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void init() {
|
||||||
|
if (allServicesInitialized && initAfterBootstrapped) {
|
||||||
// Only now we start listening and processing. The p2PDataStorage is our cache for data we have received
|
// Only now we start listening and processing. The p2PDataStorage is our cache for data we have received
|
||||||
// after the hidden service was ready.
|
// after the hidden service was ready.
|
||||||
addHashMapChangedListener();
|
addHashMapChangedListener();
|
||||||
onAdded(p2PDataStorage.getMap().values());
|
onAdded(p2PDataStorage.getMap().values());
|
||||||
maybeRepublishMailBoxMessages();
|
maybeRepublishMailBoxMessages();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public void sendEncryptedMailboxMessage(NodeAddress peer,
|
public void sendEncryptedMailboxMessage(NodeAddress peer,
|
||||||
|
@ -498,7 +513,7 @@ public class MailboxMessageService implements HashMapChangedListener, PersistedD
|
||||||
mailboxMessage.getClass().getSimpleName(), uid, sender);
|
mailboxMessage.getClass().getSimpleName(), uid, sender);
|
||||||
decryptedMailboxListeners.forEach(e -> e.onMailboxMessageAdded(decryptedMessageWithPubKey, sender));
|
decryptedMailboxListeners.forEach(e -> e.onMailboxMessageAdded(decryptedMessageWithPubKey, sender));
|
||||||
|
|
||||||
if (isBootstrapped) {
|
if (allServicesInitialized && isBootstrapped) { // GH ISSUE 6367 only remove after fully initialized
|
||||||
// After we notified our listeners we remove the data immediately from the network.
|
// After we notified our listeners we remove the data immediately from the network.
|
||||||
// In case the client has not been ready it need to take it via getMailBoxMessages.
|
// In case the client has not been ready it need to take it via getMailBoxMessages.
|
||||||
// We do not remove the data from our local map at that moment. This has to be called explicitely from the
|
// We do not remove the data from our local map at that moment. This has to be called explicitely from the
|
||||||
|
|
Loading…
Add table
Reference in a new issue