[DEADCODE] Remove protectedDataStoreListener

There were no users.
This commit is contained in:
Julian Knutsen 2019-11-19 18:35:08 -08:00
parent f3faf4bb63
commit 3503fe3b10
No known key found for this signature in database
GPG key ID: D85F536DB3615B2D
3 changed files with 9 additions and 68 deletions

View file

@ -42,7 +42,6 @@ import bisq.network.p2p.storage.payload.ProtectedStoragePayload;
import bisq.network.p2p.storage.payload.RequiresOwnerIsOnlinePayload;
import bisq.network.p2p.storage.persistence.AppendOnlyDataStoreListener;
import bisq.network.p2p.storage.persistence.AppendOnlyDataStoreService;
import bisq.network.p2p.storage.persistence.ProtectedDataStoreListener;
import bisq.network.p2p.storage.persistence.ProtectedDataStoreService;
import bisq.network.p2p.storage.persistence.ResourceDataStoreService;
import bisq.network.p2p.storage.persistence.SequenceNumberMap;
@ -126,7 +125,6 @@ public class P2PDataStorage implements MessageListener, ConnectionListener, Pers
final SequenceNumberMap sequenceNumberMap = new SequenceNumberMap();
private final Set<AppendOnlyDataStoreListener> appendOnlyDataStoreListeners = new CopyOnWriteArraySet<>();
private final Set<ProtectedDataStoreListener> protectedDataStoreListeners = new CopyOnWriteArraySet<>();
private final Clock clock;
/// The maximum number of items that must exist in the SequenceNumberMap before it is scheduled for a purge
@ -426,11 +424,9 @@ public class P2PDataStorage implements MessageListener, ConnectionListener, Pers
if (allowBroadcast)
broadcastProtectedStorageEntry(protectedStorageEntry, sender, listener, isDataOwner);
// Persist ProtectedStorageEntrys carrying PersistablePayload payloads and signal listeners on changes
if (protectedStoragePayload instanceof PersistablePayload) {
// Persist ProtectedStorageEntrys carrying PersistablePayload payloads
if (protectedStoragePayload instanceof PersistablePayload)
protectedDataStoreService.put(hashOfPayload, protectedStorageEntry);
protectedDataStoreListeners.forEach(e -> e.onAdded(protectedStorageEntry));
}
return true;
}
@ -631,17 +627,6 @@ public class P2PDataStorage implements MessageListener, ConnectionListener, Pers
appendOnlyDataStoreListeners.remove(listener);
}
@SuppressWarnings("unused")
public void addProtectedDataStoreListener(ProtectedDataStoreListener listener) {
protectedDataStoreListeners.add(listener);
}
@SuppressWarnings("unused")
public void removeProtectedDataStoreListener(ProtectedDataStoreListener listener) {
protectedDataStoreListeners.remove(listener);
}
///////////////////////////////////////////////////////////////////////////////////////////
// Private
///////////////////////////////////////////////////////////////////////////////////////////
@ -667,11 +652,8 @@ public class P2PDataStorage implements MessageListener, ConnectionListener, Pers
ProtectedStoragePayload protectedStoragePayload = protectedStorageEntry.getProtectedStoragePayload();
if (protectedStoragePayload instanceof PersistablePayload) {
ProtectedStorageEntry previous = protectedDataStoreService.remove(hashOfPayload, protectedStorageEntry);
if (previous != null) {
protectedDataStoreListeners.forEach(e -> e.onRemoved(protectedStorageEntry));
} else {
log.info("We cannot remove the protectedStorageEntry from the persistedEntryMap as it does not exist.");
}
if (previous == null)
log.error("We cannot remove the protectedStorageEntry from the persistedEntryMap as it does not exist.");
}
});

View file

@ -1,26 +0,0 @@
/*
* This file is part of Bisq.
*
* Bisq is free software: you can redistribute it and/or modify it
* under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or (at
* your option) any later version.
*
* Bisq is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public
* License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with Bisq. If not, see <http://www.gnu.org/licenses/>.
*/
package bisq.network.p2p.storage.persistence;
import bisq.network.p2p.storage.payload.ProtectedStorageEntry;
public interface ProtectedDataStoreListener {
void onAdded(ProtectedStorageEntry protectedStorageEntry);
void onRemoved(ProtectedStorageEntry protectedStorageEntry);
}

View file

@ -35,8 +35,6 @@ import bisq.network.p2p.storage.payload.PersistableNetworkPayload;
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.MapStoreService;
import bisq.network.p2p.storage.persistence.ProtectedDataStoreListener;
import bisq.network.p2p.storage.persistence.ProtectedDataStoreService;
import bisq.network.p2p.storage.persistence.ResourceDataStoreService;
import bisq.network.p2p.storage.persistence.SequenceNumberMap;
@ -71,7 +69,6 @@ public class TestState {
final Broadcaster mockBroadcaster;
final AppendOnlyDataStoreListener appendOnlyDataStoreListener;
private final ProtectedDataStoreListener protectedDataStoreListener;
private final HashMapChangedListener hashMapChangedListener;
private final Storage<SequenceNumberMap> mockSeqNrStorage;
private final ProtectedDataStoreService protectedDataStoreService;
@ -90,7 +87,6 @@ public class TestState {
this.mockSeqNrStorage, this.clockFake, MAX_SEQUENCE_NUMBER_MAP_SIZE_BEFORE_PURGE);
this.appendOnlyDataStoreListener = mock(AppendOnlyDataStoreListener.class);
this.protectedDataStoreListener = mock(ProtectedDataStoreListener.class);
this.hashMapChangedListener = mock(HashMapChangedListener.class);
this.protectedDataStoreService.addService(new MapStoreServiceFake());
@ -100,8 +96,7 @@ public class TestState {
this.mockSeqNrStorage,
this.clockFake,
this.hashMapChangedListener,
this.appendOnlyDataStoreListener,
this.protectedDataStoreListener);
this.appendOnlyDataStoreListener);
}
@ -120,8 +115,7 @@ public class TestState {
this.mockSeqNrStorage,
this.clockFake,
this.hashMapChangedListener,
this.appendOnlyDataStoreListener,
this.protectedDataStoreListener);
this.appendOnlyDataStoreListener);
}
private static P2PDataStorage createP2PDataStorageForTest(
@ -130,8 +124,7 @@ public class TestState {
Storage<SequenceNumberMap> sequenceNrMapStorage,
ClockFake clock,
HashMapChangedListener hashMapChangedListener,
AppendOnlyDataStoreListener appendOnlyDataStoreListener,
ProtectedDataStoreListener protectedDataStoreListener) {
AppendOnlyDataStoreListener appendOnlyDataStoreListener) {
P2PDataStorage p2PDataStorage = new P2PDataStorage(mock(NetworkNode.class),
broadcaster,
@ -145,7 +138,6 @@ public class TestState {
p2PDataStorage.addHashMapChangedListener(hashMapChangedListener);
p2PDataStorage.addAppendOnlyDataStoreListener(appendOnlyDataStoreListener);
p2PDataStorage.addProtectedDataStoreListener(protectedDataStoreListener);
return p2PDataStorage;
}
@ -153,7 +145,6 @@ public class TestState {
private void resetState() {
reset(this.mockBroadcaster);
reset(this.appendOnlyDataStoreListener);
reset(this.protectedDataStoreListener);
reset(this.hashMapChangedListener);
reset(this.mockSeqNrStorage);
}
@ -221,10 +212,8 @@ public class TestState {
if (expectedStateChange) {
Assert.assertEquals(protectedStorageEntry, this.mockedStorage.getMap().get(hashMapHash));
if (protectedStorageEntry.getProtectedStoragePayload() instanceof PersistablePayload) {
if (protectedStorageEntry.getProtectedStoragePayload() instanceof PersistablePayload)
Assert.assertEquals(protectedStorageEntry, this.protectedDataStoreService.getMap().get(hashMapHash));
verify(this.protectedDataStoreListener).onAdded(protectedStorageEntry);
}
verify(this.hashMapChangedListener).onAdded(Collections.singletonList(protectedStorageEntry));
@ -245,7 +234,6 @@ public class TestState {
// Internal state didn't change... nothing should be notified
verify(this.hashMapChangedListener, never()).onAdded(Collections.singletonList(protectedStorageEntry));
verify(this.protectedDataStoreListener, never()).onAdded(protectedStorageEntry);
verify(this.mockSeqNrStorage, never()).queueUpForSave(any(SequenceNumberMap.class), anyLong());
}
}
@ -286,7 +274,6 @@ public class TestState {
Assert.assertEquals(expected, actual);
} else {
verify(this.hashMapChangedListener, never()).onRemoved(any());
verify(this.protectedDataStoreListener, never()).onAdded(any());
}
if (!expectedSeqNrWrite)
@ -314,11 +301,9 @@ public class TestState {
if (expectedHashMapAndDataStoreUpdated) {
Assert.assertNull(this.mockedStorage.getMap().get(hashMapHash));
if (protectedStorageEntry.getProtectedStoragePayload() instanceof PersistablePayload) {
if (protectedStorageEntry.getProtectedStoragePayload() instanceof PersistablePayload)
Assert.assertNull(this.protectedDataStoreService.getMap().get(hashMapHash));
verify(this.protectedDataStoreListener).onRemoved(protectedStorageEntry);
}
} else {
Assert.assertEquals(beforeState.protectedStorageEntryBeforeOp, this.mockedStorage.getMap().get(hashMapHash));
}