diff --git a/desktop/src/main/java/bisq/desktop/main/market/trades/TradesChartsViewModel.java b/desktop/src/main/java/bisq/desktop/main/market/trades/TradesChartsViewModel.java index 5227a4d00d..b56073f48b 100644 --- a/desktop/src/main/java/bisq/desktop/main/market/trades/TradesChartsViewModel.java +++ b/desktop/src/main/java/bisq/desktop/main/market/trades/TradesChartsViewModel.java @@ -117,7 +117,7 @@ class TradesChartsViewModel extends ActivatableViewModel { final int maxTicks = 90; private int selectedTabIndex; final Map> usdPriceMapsPerTickUnit = new HashMap<>(); - private boolean fillTradeCurrenciesOnActiavetCalled; + private boolean fillTradeCurrenciesOnActivateCalled; /////////////////////////////////////////////////////////////////////////////////////////// // Constructor, lifecycle @@ -152,9 +152,9 @@ class TradesChartsViewModel extends ActivatableViewModel { @Override protected void activate() { tradeStatisticsManager.getObservableTradeStatisticsSet().addListener(setChangeListener); - if (!fillTradeCurrenciesOnActiavetCalled) { + if (!fillTradeCurrenciesOnActivateCalled) { fillTradeCurrencies(); - fillTradeCurrenciesOnActiavetCalled = true; + fillTradeCurrenciesOnActivateCalled = true; } buildUsdPricesPerDay(); updateSelectedTradeStatistics(getCurrencyCode()); diff --git a/p2p/src/main/java/bisq/network/p2p/mailbox/MailboxItem.java b/p2p/src/main/java/bisq/network/p2p/mailbox/MailboxItem.java index 3d3ff79cd7..aebf271fef 100644 --- a/p2p/src/main/java/bisq/network/p2p/mailbox/MailboxItem.java +++ b/p2p/src/main/java/bisq/network/p2p/mailbox/MailboxItem.java @@ -32,8 +32,6 @@ import lombok.Value; import javax.annotation.Nullable; -import static com.google.common.base.Preconditions.checkNotNull; - @Value public class MailboxItem implements PersistablePayload { private final ProtectedMailboxStorageEntry protectedMailboxStorageEntry; @@ -78,7 +76,7 @@ public class MailboxItem implements PersistablePayload { 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(); + MailboxMessage mailboxMessage = (MailboxMessage) decryptedMessageWithPubKey.getNetworkEnvelope(); return mailboxMessage.getUid(); } else { // If its not our mailbox msg we take the uid from the prefixedSealedAndSignedMessage instead. diff --git a/p2p/src/main/java/bisq/network/p2p/mailbox/MailboxMessageService.java b/p2p/src/main/java/bisq/network/p2p/mailbox/MailboxMessageService.java index 171fc1035d..1d41463f6c 100644 --- a/p2p/src/main/java/bisq/network/p2p/mailbox/MailboxMessageService.java +++ b/p2p/src/main/java/bisq/network/p2p/mailbox/MailboxMessageService.java @@ -430,7 +430,6 @@ public class MailboxMessageService implements SetupListener, RequestDataManager. if (ignoredMailboxService.isIgnored(uid)) { // We had persisted a past failed decryption attempt on that message so we don't try again and return early return new MailboxItem(protectedMailboxStorageEntry, null); - } try { DecryptedMessageWithPubKey decryptedMessageWithPubKey = encryptionService.decryptAndVerify(sealedAndSigned); @@ -445,7 +444,6 @@ public class MailboxMessageService implements SetupListener, RequestDataManager. e.getStackTrace(); } return new MailboxItem(protectedMailboxStorageEntry, null); - } private void handleMailboxItem(MailboxItem mailboxItem) { diff --git a/p2p/src/main/java/bisq/network/p2p/storage/persistence/RemovedPayloadsService.java b/p2p/src/main/java/bisq/network/p2p/storage/persistence/RemovedPayloadsService.java index 8e22cc571a..af0a80f56a 100644 --- a/p2p/src/main/java/bisq/network/p2p/storage/persistence/RemovedPayloadsService.java +++ b/p2p/src/main/java/bisq/network/p2p/storage/persistence/RemovedPayloadsService.java @@ -28,6 +28,11 @@ import javax.inject.Singleton; import lombok.extern.slf4j.Slf4j; +/** + * We persist the hashes and timestamp when a AddOncePayload payload got removed. This protects that it could be + * added again for instance if the sequence number map would be inconsistent/deleted or when we receive data from + * seed nodes where we do skip some checks. + */ @Singleton @Slf4j public class RemovedPayloadsService implements PersistedDataHost { @@ -51,7 +56,7 @@ public class RemovedPayloadsService implements PersistedDataHost { long cutOffDate = System.currentTimeMillis() - MailboxStoragePayload.TTL; persistenceManager.readPersisted(persisted -> { persisted.getDateByHashes().entrySet().stream() - .filter(e -> e.getValue() < cutOffDate) + .filter(e -> e.getValue() > cutOffDate) .forEach(e -> removedPayloadsMap.getDateByHashes().put(e.getKey(), e.getValue())); log.trace("readPersisted: removedPayloadsMap={}", removedPayloadsMap); persistenceManager.requestPersistence(); @@ -67,7 +72,7 @@ public class RemovedPayloadsService implements PersistedDataHost { public void addHash(P2PDataStorage.ByteArray hashOfPayload) { log.trace("called addHash: hashOfPayload={}, removedPayloadsMap={}", hashOfPayload.toString(), removedPayloadsMap); - removedPayloadsMap.getDateByHashes().put(hashOfPayload, System.currentTimeMillis()); + removedPayloadsMap.getDateByHashes().putIfAbsent(hashOfPayload, System.currentTimeMillis()); persistenceManager.requestPersistence(); } }