From 41a92eae7f247960425df2c939f1743a97fd4be8 Mon Sep 17 00:00:00 2001 From: chimp1984 Date: Sun, 10 Jan 2021 22:59:56 -0500 Subject: [PATCH] Refactor: Rename class --- .../bisq/core/setup/CorePersistedDataHost.java | 4 ++-- .../network/p2p/storage/P2PDataStorage.java | 12 ++++++------ ...ervice.java => RemovedPayloadsService.java} | 4 ++-- .../bisq/network/p2p/storage/TestState.java | 18 +++++++++--------- 4 files changed, 19 insertions(+), 19 deletions(-) rename p2p/src/main/java/bisq/network/p2p/storage/persistence/{RemovedPayloadsStorageService.java => RemovedPayloadsService.java} (93%) diff --git a/core/src/main/java/bisq/core/setup/CorePersistedDataHost.java b/core/src/main/java/bisq/core/setup/CorePersistedDataHost.java index c70642d432..0e54e5527c 100644 --- a/core/src/main/java/bisq/core/setup/CorePersistedDataHost.java +++ b/core/src/main/java/bisq/core/setup/CorePersistedDataHost.java @@ -39,7 +39,7 @@ import bisq.network.p2p.mailbox.IgnoredMailboxService; import bisq.network.p2p.mailbox.MailboxMessageService; import bisq.network.p2p.peers.PeerManager; import bisq.network.p2p.storage.P2PDataStorage; -import bisq.network.p2p.storage.persistence.RemovedPayloadsStorageService; +import bisq.network.p2p.storage.persistence.RemovedPayloadsService; import bisq.common.config.Config; import bisq.common.proto.persistable.PersistedDataHost; @@ -71,7 +71,7 @@ public class CorePersistedDataHost { persistedDataHosts.add(injector.getInstance(PeerManager.class)); persistedDataHosts.add(injector.getInstance(MailboxMessageService.class)); persistedDataHosts.add(injector.getInstance(IgnoredMailboxService.class)); - persistedDataHosts.add(injector.getInstance(RemovedPayloadsStorageService.class)); + persistedDataHosts.add(injector.getInstance(RemovedPayloadsService.class)); if (injector.getInstance(Config.class).daoActivated) { persistedDataHosts.add(injector.getInstance(BallotListService.class)); diff --git a/p2p/src/main/java/bisq/network/p2p/storage/P2PDataStorage.java b/p2p/src/main/java/bisq/network/p2p/storage/P2PDataStorage.java index 804182101a..6b47ef22b6 100644 --- a/p2p/src/main/java/bisq/network/p2p/storage/P2PDataStorage.java +++ b/p2p/src/main/java/bisq/network/p2p/storage/P2PDataStorage.java @@ -51,7 +51,7 @@ import bisq.network.p2p.storage.persistence.AppendOnlyDataStoreService; import bisq.network.p2p.storage.persistence.HistoricalDataStoreService; import bisq.network.p2p.storage.persistence.PersistableNetworkPayloadStore; import bisq.network.p2p.storage.persistence.ProtectedDataStoreService; -import bisq.network.p2p.storage.persistence.RemovedPayloadsStorageService; +import bisq.network.p2p.storage.persistence.RemovedPayloadsService; import bisq.network.p2p.storage.persistence.ResourceDataStoreService; import bisq.network.p2p.storage.persistence.SequenceNumberMap; @@ -143,7 +143,7 @@ public class P2PDataStorage implements MessageListener, ConnectionListener, Pers final SequenceNumberMap sequenceNumberMap = new SequenceNumberMap(); private final Set appendOnlyDataStoreListeners = new CopyOnWriteArraySet<>(); - private final RemovedPayloadsStorageService removedPayloadsStorageService; + private final RemovedPayloadsService removedPayloadsService; private final Clock clock; /// The maximum number of items that must exist in the SequenceNumberMap before it is scheduled for a purge @@ -165,7 +165,7 @@ public class P2PDataStorage implements MessageListener, ConnectionListener, Pers ProtectedDataStoreService protectedDataStoreService, ResourceDataStoreService resourceDataStoreService, PersistenceManager persistenceManager, - RemovedPayloadsStorageService removedPayloadsStorageService, + RemovedPayloadsService removedPayloadsService, Clock clock, @Named("MAX_SEQUENCE_NUMBER_MAP_SIZE_BEFORE_PURGE") int maxSequenceNumberBeforePurge) { this.broadcaster = broadcaster; @@ -173,7 +173,7 @@ public class P2PDataStorage implements MessageListener, ConnectionListener, Pers this.protectedDataStoreService = protectedDataStoreService; this.resourceDataStoreService = resourceDataStoreService; this.persistenceManager = persistenceManager; - this.removedPayloadsStorageService = removedPayloadsStorageService; + this.removedPayloadsService = removedPayloadsService; this.clock = clock; this.maxSequenceNumberMapSizeBeforePurge = maxSequenceNumberBeforePurge; @@ -772,7 +772,7 @@ public class P2PDataStorage implements MessageListener, ConnectionListener, Pers public boolean hasAlreadyRemovedAddOncePayload(ProtectedStoragePayload protectedStoragePayload, ByteArray hashOfPayload) { - return protectedStoragePayload instanceof AddOncePayload && removedPayloadsStorageService.wasRemoved(hashOfPayload); + return protectedStoragePayload instanceof AddOncePayload && removedPayloadsService.wasRemoved(hashOfPayload); } /** @@ -856,7 +856,7 @@ public class P2PDataStorage implements MessageListener, ConnectionListener, Pers // Update that we have seen this AddOncePayload so the next time it is seen it fails verification if (protectedStoragePayload instanceof AddOncePayload) { - removedPayloadsStorageService.addHash(hashOfPayload); + removedPayloadsService.addHash(hashOfPayload); } if (storedEntry != null) { diff --git a/p2p/src/main/java/bisq/network/p2p/storage/persistence/RemovedPayloadsStorageService.java b/p2p/src/main/java/bisq/network/p2p/storage/persistence/RemovedPayloadsService.java similarity index 93% rename from p2p/src/main/java/bisq/network/p2p/storage/persistence/RemovedPayloadsStorageService.java rename to p2p/src/main/java/bisq/network/p2p/storage/persistence/RemovedPayloadsService.java index d44919d3a9..164bde1828 100644 --- a/p2p/src/main/java/bisq/network/p2p/storage/persistence/RemovedPayloadsStorageService.java +++ b/p2p/src/main/java/bisq/network/p2p/storage/persistence/RemovedPayloadsService.java @@ -30,12 +30,12 @@ import lombok.extern.slf4j.Slf4j; @Singleton @Slf4j -public class RemovedPayloadsStorageService implements PersistedDataHost { +public class RemovedPayloadsService implements PersistedDataHost { private final PersistenceManager persistenceManager; private final RemovedPayloadsMap removedPayloadsMap = new RemovedPayloadsMap(); @Inject - public RemovedPayloadsStorageService(PersistenceManager persistenceManager) { + public RemovedPayloadsService(PersistenceManager persistenceManager) { this.persistenceManager = persistenceManager; this.persistenceManager.initialize(removedPayloadsMap, PersistenceManager.Source.PRIVATE_LOW_PRIO); diff --git a/p2p/src/test/java/bisq/network/p2p/storage/TestState.java b/p2p/src/test/java/bisq/network/p2p/storage/TestState.java index d35c39d880..e807bc9d7e 100644 --- a/p2p/src/test/java/bisq/network/p2p/storage/TestState.java +++ b/p2p/src/test/java/bisq/network/p2p/storage/TestState.java @@ -35,7 +35,7 @@ import bisq.network.p2p.storage.payload.ProtectedMailboxStorageEntry; import bisq.network.p2p.storage.payload.ProtectedStorageEntry; import bisq.network.p2p.storage.persistence.AppendOnlyDataStoreListener; import bisq.network.p2p.storage.persistence.ProtectedDataStoreService; -import bisq.network.p2p.storage.persistence.RemovedPayloadsStorageService; +import bisq.network.p2p.storage.persistence.RemovedPayloadsService; import bisq.network.p2p.storage.persistence.ResourceDataStoreService; import bisq.network.p2p.storage.persistence.SequenceNumberMap; @@ -73,12 +73,12 @@ public class TestState { private final PersistenceManager mockSeqNrPersistenceManager; private final ProtectedDataStoreService protectedDataStoreService; final ClockFake clockFake; - private RemovedPayloadsStorageService removedPayloadsStorageService; + private RemovedPayloadsService removedPayloadsService; TestState() { this.mockBroadcaster = mock(Broadcaster.class); this.mockSeqNrPersistenceManager = mock(PersistenceManager.class); - this.removedPayloadsStorageService = mock(RemovedPayloadsStorageService.class); + this.removedPayloadsService = mock(RemovedPayloadsService.class); this.clockFake = new ClockFake(); this.protectedDataStoreService = new ProtectedDataStoreService(); @@ -87,7 +87,7 @@ public class TestState { new AppendOnlyDataStoreServiceFake(), this.protectedDataStoreService, mock(ResourceDataStoreService.class), this.mockSeqNrPersistenceManager, - removedPayloadsStorageService, + removedPayloadsService, this.clockFake, MAX_SEQUENCE_NUMBER_MAP_SIZE_BEFORE_PURGE); @@ -102,7 +102,7 @@ public class TestState { this.clockFake, this.hashMapChangedListener, this.appendOnlyDataStoreListener, - removedPayloadsStorageService); + removedPayloadsService); when(this.mockSeqNrPersistenceManager.getPersisted()) .thenReturn(this.mockedStorage.sequenceNumberMap); @@ -115,7 +115,7 @@ public class TestState { * not running the entire storage code paths. */ void simulateRestart() { - this.removedPayloadsStorageService = mock(RemovedPayloadsStorageService.class); + this.removedPayloadsService = mock(RemovedPayloadsService.class); this.mockedStorage = createP2PDataStorageForTest( this.mockBroadcaster, this.protectedDataStoreService, @@ -123,7 +123,7 @@ public class TestState { this.clockFake, this.hashMapChangedListener, this.appendOnlyDataStoreListener, - removedPayloadsStorageService); + removedPayloadsService); when(this.mockSeqNrPersistenceManager.getPersisted()) .thenReturn(this.mockedStorage.sequenceNumberMap); @@ -136,7 +136,7 @@ public class TestState { ClockFake clock, HashMapChangedListener hashMapChangedListener, AppendOnlyDataStoreListener appendOnlyDataStoreListener, - RemovedPayloadsStorageService removedPayloadsStorageService) { + RemovedPayloadsService removedPayloadsService) { P2PDataStorage p2PDataStorage = new P2PDataStorage(mock(NetworkNode.class), broadcaster, @@ -144,7 +144,7 @@ public class TestState { protectedDataStoreService, mock(ResourceDataStoreService.class), sequenceNrMapPersistenceManager, - removedPayloadsStorageService, + removedPayloadsService, clock, MAX_SEQUENCE_NUMBER_MAP_SIZE_BEFORE_PURGE);