mirror of
https://github.com/bisq-network/bisq.git
synced 2024-11-19 09:52:23 +01:00
Fix incorrect comparison at RemovedPayloadsService.readPersisted
Add comments Cleanups
This commit is contained in:
parent
d39a697611
commit
b4ab8a4a0d
@ -117,7 +117,7 @@ class TradesChartsViewModel extends ActivatableViewModel {
|
||||
final int maxTicks = 90;
|
||||
private int selectedTabIndex;
|
||||
final Map<TickUnit, Map<Long, Long>> 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());
|
||||
|
@ -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.
|
||||
|
@ -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) {
|
||||
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user