mirror of
https://github.com/bisq-network/bisq.git
synced 2025-02-24 07:07:43 +01:00
[DEADCODE] Remove protectedDataStoreListener
There were no users.
This commit is contained in:
parent
f3faf4bb63
commit
3503fe3b10
3 changed files with 9 additions and 68 deletions
|
@ -42,7 +42,6 @@ import bisq.network.p2p.storage.payload.ProtectedStoragePayload;
|
||||||
import bisq.network.p2p.storage.payload.RequiresOwnerIsOnlinePayload;
|
import bisq.network.p2p.storage.payload.RequiresOwnerIsOnlinePayload;
|
||||||
import bisq.network.p2p.storage.persistence.AppendOnlyDataStoreListener;
|
import bisq.network.p2p.storage.persistence.AppendOnlyDataStoreListener;
|
||||||
import bisq.network.p2p.storage.persistence.AppendOnlyDataStoreService;
|
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.ProtectedDataStoreService;
|
||||||
import bisq.network.p2p.storage.persistence.ResourceDataStoreService;
|
import bisq.network.p2p.storage.persistence.ResourceDataStoreService;
|
||||||
import bisq.network.p2p.storage.persistence.SequenceNumberMap;
|
import bisq.network.p2p.storage.persistence.SequenceNumberMap;
|
||||||
|
@ -126,7 +125,6 @@ public class P2PDataStorage implements MessageListener, ConnectionListener, Pers
|
||||||
final SequenceNumberMap sequenceNumberMap = new SequenceNumberMap();
|
final SequenceNumberMap sequenceNumberMap = new SequenceNumberMap();
|
||||||
|
|
||||||
private final Set<AppendOnlyDataStoreListener> appendOnlyDataStoreListeners = new CopyOnWriteArraySet<>();
|
private final Set<AppendOnlyDataStoreListener> appendOnlyDataStoreListeners = new CopyOnWriteArraySet<>();
|
||||||
private final Set<ProtectedDataStoreListener> protectedDataStoreListeners = new CopyOnWriteArraySet<>();
|
|
||||||
private final Clock clock;
|
private final Clock clock;
|
||||||
|
|
||||||
/// The maximum number of items that must exist in the SequenceNumberMap before it is scheduled for a purge
|
/// 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)
|
if (allowBroadcast)
|
||||||
broadcastProtectedStorageEntry(protectedStorageEntry, sender, listener, isDataOwner);
|
broadcastProtectedStorageEntry(protectedStorageEntry, sender, listener, isDataOwner);
|
||||||
|
|
||||||
// Persist ProtectedStorageEntrys carrying PersistablePayload payloads and signal listeners on changes
|
// Persist ProtectedStorageEntrys carrying PersistablePayload payloads
|
||||||
if (protectedStoragePayload instanceof PersistablePayload) {
|
if (protectedStoragePayload instanceof PersistablePayload)
|
||||||
protectedDataStoreService.put(hashOfPayload, protectedStorageEntry);
|
protectedDataStoreService.put(hashOfPayload, protectedStorageEntry);
|
||||||
protectedDataStoreListeners.forEach(e -> e.onAdded(protectedStorageEntry));
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -631,17 +627,6 @@ public class P2PDataStorage implements MessageListener, ConnectionListener, Pers
|
||||||
appendOnlyDataStoreListeners.remove(listener);
|
appendOnlyDataStoreListeners.remove(listener);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unused")
|
|
||||||
public void addProtectedDataStoreListener(ProtectedDataStoreListener listener) {
|
|
||||||
protectedDataStoreListeners.add(listener);
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("unused")
|
|
||||||
public void removeProtectedDataStoreListener(ProtectedDataStoreListener listener) {
|
|
||||||
protectedDataStoreListeners.remove(listener);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// Private
|
// Private
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -667,11 +652,8 @@ public class P2PDataStorage implements MessageListener, ConnectionListener, Pers
|
||||||
ProtectedStoragePayload protectedStoragePayload = protectedStorageEntry.getProtectedStoragePayload();
|
ProtectedStoragePayload protectedStoragePayload = protectedStorageEntry.getProtectedStoragePayload();
|
||||||
if (protectedStoragePayload instanceof PersistablePayload) {
|
if (protectedStoragePayload instanceof PersistablePayload) {
|
||||||
ProtectedStorageEntry previous = protectedDataStoreService.remove(hashOfPayload, protectedStorageEntry);
|
ProtectedStorageEntry previous = protectedDataStoreService.remove(hashOfPayload, protectedStorageEntry);
|
||||||
if (previous != null) {
|
if (previous == null)
|
||||||
protectedDataStoreListeners.forEach(e -> e.onRemoved(protectedStorageEntry));
|
log.error("We cannot remove the protectedStorageEntry from the persistedEntryMap as it does not exist.");
|
||||||
} else {
|
|
||||||
log.info("We cannot remove the protectedStorageEntry from the persistedEntryMap as it does not exist.");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -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);
|
|
||||||
}
|
|
|
@ -35,8 +35,6 @@ import bisq.network.p2p.storage.payload.PersistableNetworkPayload;
|
||||||
import bisq.network.p2p.storage.payload.ProtectedMailboxStorageEntry;
|
import bisq.network.p2p.storage.payload.ProtectedMailboxStorageEntry;
|
||||||
import bisq.network.p2p.storage.payload.ProtectedStorageEntry;
|
import bisq.network.p2p.storage.payload.ProtectedStorageEntry;
|
||||||
import bisq.network.p2p.storage.persistence.AppendOnlyDataStoreListener;
|
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.ProtectedDataStoreService;
|
||||||
import bisq.network.p2p.storage.persistence.ResourceDataStoreService;
|
import bisq.network.p2p.storage.persistence.ResourceDataStoreService;
|
||||||
import bisq.network.p2p.storage.persistence.SequenceNumberMap;
|
import bisq.network.p2p.storage.persistence.SequenceNumberMap;
|
||||||
|
@ -71,7 +69,6 @@ public class TestState {
|
||||||
final Broadcaster mockBroadcaster;
|
final Broadcaster mockBroadcaster;
|
||||||
|
|
||||||
final AppendOnlyDataStoreListener appendOnlyDataStoreListener;
|
final AppendOnlyDataStoreListener appendOnlyDataStoreListener;
|
||||||
private final ProtectedDataStoreListener protectedDataStoreListener;
|
|
||||||
private final HashMapChangedListener hashMapChangedListener;
|
private final HashMapChangedListener hashMapChangedListener;
|
||||||
private final Storage<SequenceNumberMap> mockSeqNrStorage;
|
private final Storage<SequenceNumberMap> mockSeqNrStorage;
|
||||||
private final ProtectedDataStoreService protectedDataStoreService;
|
private final ProtectedDataStoreService protectedDataStoreService;
|
||||||
|
@ -90,7 +87,6 @@ public class TestState {
|
||||||
this.mockSeqNrStorage, this.clockFake, MAX_SEQUENCE_NUMBER_MAP_SIZE_BEFORE_PURGE);
|
this.mockSeqNrStorage, this.clockFake, MAX_SEQUENCE_NUMBER_MAP_SIZE_BEFORE_PURGE);
|
||||||
|
|
||||||
this.appendOnlyDataStoreListener = mock(AppendOnlyDataStoreListener.class);
|
this.appendOnlyDataStoreListener = mock(AppendOnlyDataStoreListener.class);
|
||||||
this.protectedDataStoreListener = mock(ProtectedDataStoreListener.class);
|
|
||||||
this.hashMapChangedListener = mock(HashMapChangedListener.class);
|
this.hashMapChangedListener = mock(HashMapChangedListener.class);
|
||||||
this.protectedDataStoreService.addService(new MapStoreServiceFake());
|
this.protectedDataStoreService.addService(new MapStoreServiceFake());
|
||||||
|
|
||||||
|
@ -100,8 +96,7 @@ public class TestState {
|
||||||
this.mockSeqNrStorage,
|
this.mockSeqNrStorage,
|
||||||
this.clockFake,
|
this.clockFake,
|
||||||
this.hashMapChangedListener,
|
this.hashMapChangedListener,
|
||||||
this.appendOnlyDataStoreListener,
|
this.appendOnlyDataStoreListener);
|
||||||
this.protectedDataStoreListener);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -120,8 +115,7 @@ public class TestState {
|
||||||
this.mockSeqNrStorage,
|
this.mockSeqNrStorage,
|
||||||
this.clockFake,
|
this.clockFake,
|
||||||
this.hashMapChangedListener,
|
this.hashMapChangedListener,
|
||||||
this.appendOnlyDataStoreListener,
|
this.appendOnlyDataStoreListener);
|
||||||
this.protectedDataStoreListener);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static P2PDataStorage createP2PDataStorageForTest(
|
private static P2PDataStorage createP2PDataStorageForTest(
|
||||||
|
@ -130,8 +124,7 @@ public class TestState {
|
||||||
Storage<SequenceNumberMap> sequenceNrMapStorage,
|
Storage<SequenceNumberMap> sequenceNrMapStorage,
|
||||||
ClockFake clock,
|
ClockFake clock,
|
||||||
HashMapChangedListener hashMapChangedListener,
|
HashMapChangedListener hashMapChangedListener,
|
||||||
AppendOnlyDataStoreListener appendOnlyDataStoreListener,
|
AppendOnlyDataStoreListener appendOnlyDataStoreListener) {
|
||||||
ProtectedDataStoreListener protectedDataStoreListener) {
|
|
||||||
|
|
||||||
P2PDataStorage p2PDataStorage = new P2PDataStorage(mock(NetworkNode.class),
|
P2PDataStorage p2PDataStorage = new P2PDataStorage(mock(NetworkNode.class),
|
||||||
broadcaster,
|
broadcaster,
|
||||||
|
@ -145,7 +138,6 @@ public class TestState {
|
||||||
|
|
||||||
p2PDataStorage.addHashMapChangedListener(hashMapChangedListener);
|
p2PDataStorage.addHashMapChangedListener(hashMapChangedListener);
|
||||||
p2PDataStorage.addAppendOnlyDataStoreListener(appendOnlyDataStoreListener);
|
p2PDataStorage.addAppendOnlyDataStoreListener(appendOnlyDataStoreListener);
|
||||||
p2PDataStorage.addProtectedDataStoreListener(protectedDataStoreListener);
|
|
||||||
|
|
||||||
return p2PDataStorage;
|
return p2PDataStorage;
|
||||||
}
|
}
|
||||||
|
@ -153,7 +145,6 @@ public class TestState {
|
||||||
private void resetState() {
|
private void resetState() {
|
||||||
reset(this.mockBroadcaster);
|
reset(this.mockBroadcaster);
|
||||||
reset(this.appendOnlyDataStoreListener);
|
reset(this.appendOnlyDataStoreListener);
|
||||||
reset(this.protectedDataStoreListener);
|
|
||||||
reset(this.hashMapChangedListener);
|
reset(this.hashMapChangedListener);
|
||||||
reset(this.mockSeqNrStorage);
|
reset(this.mockSeqNrStorage);
|
||||||
}
|
}
|
||||||
|
@ -221,10 +212,8 @@ public class TestState {
|
||||||
if (expectedStateChange) {
|
if (expectedStateChange) {
|
||||||
Assert.assertEquals(protectedStorageEntry, this.mockedStorage.getMap().get(hashMapHash));
|
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));
|
Assert.assertEquals(protectedStorageEntry, this.protectedDataStoreService.getMap().get(hashMapHash));
|
||||||
verify(this.protectedDataStoreListener).onAdded(protectedStorageEntry);
|
|
||||||
}
|
|
||||||
|
|
||||||
verify(this.hashMapChangedListener).onAdded(Collections.singletonList(protectedStorageEntry));
|
verify(this.hashMapChangedListener).onAdded(Collections.singletonList(protectedStorageEntry));
|
||||||
|
|
||||||
|
@ -245,7 +234,6 @@ public class TestState {
|
||||||
|
|
||||||
// Internal state didn't change... nothing should be notified
|
// Internal state didn't change... nothing should be notified
|
||||||
verify(this.hashMapChangedListener, never()).onAdded(Collections.singletonList(protectedStorageEntry));
|
verify(this.hashMapChangedListener, never()).onAdded(Collections.singletonList(protectedStorageEntry));
|
||||||
verify(this.protectedDataStoreListener, never()).onAdded(protectedStorageEntry);
|
|
||||||
verify(this.mockSeqNrStorage, never()).queueUpForSave(any(SequenceNumberMap.class), anyLong());
|
verify(this.mockSeqNrStorage, never()).queueUpForSave(any(SequenceNumberMap.class), anyLong());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -286,7 +274,6 @@ public class TestState {
|
||||||
Assert.assertEquals(expected, actual);
|
Assert.assertEquals(expected, actual);
|
||||||
} else {
|
} else {
|
||||||
verify(this.hashMapChangedListener, never()).onRemoved(any());
|
verify(this.hashMapChangedListener, never()).onRemoved(any());
|
||||||
verify(this.protectedDataStoreListener, never()).onAdded(any());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!expectedSeqNrWrite)
|
if (!expectedSeqNrWrite)
|
||||||
|
@ -314,11 +301,9 @@ public class TestState {
|
||||||
if (expectedHashMapAndDataStoreUpdated) {
|
if (expectedHashMapAndDataStoreUpdated) {
|
||||||
Assert.assertNull(this.mockedStorage.getMap().get(hashMapHash));
|
Assert.assertNull(this.mockedStorage.getMap().get(hashMapHash));
|
||||||
|
|
||||||
if (protectedStorageEntry.getProtectedStoragePayload() instanceof PersistablePayload) {
|
if (protectedStorageEntry.getProtectedStoragePayload() instanceof PersistablePayload)
|
||||||
Assert.assertNull(this.protectedDataStoreService.getMap().get(hashMapHash));
|
Assert.assertNull(this.protectedDataStoreService.getMap().get(hashMapHash));
|
||||||
|
|
||||||
verify(this.protectedDataStoreListener).onRemoved(protectedStorageEntry);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
Assert.assertEquals(beforeState.protectedStorageEntryBeforeOp, this.mockedStorage.getMap().get(hashMapHash));
|
Assert.assertEquals(beforeState.protectedStorageEntryBeforeOp, this.mockedStorage.getMap().get(hashMapHash));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue