mirror of
https://github.com/bisq-network/bisq.git
synced 2024-11-19 09:52:23 +01:00
Change removeFromMapAndDataStore to signal listeners at the end in a batch
All current users still call this one-at-a-time. But, it gives the ability for the expire code path to remove in a batch.
This commit is contained in:
parent
4f08588717
commit
489b25aa13
@ -651,12 +651,17 @@ public class P2PDataStorage implements MessageListener, ConnectionListener, Pers
|
||||
|
||||
private void removeFromMapAndDataStore(
|
||||
Collection<Map.Entry<ByteArray, ProtectedStorageEntry>> entriesToRemoveWithPayloadHash) {
|
||||
|
||||
if (entriesToRemoveWithPayloadHash.isEmpty())
|
||||
return;
|
||||
|
||||
ArrayList<ProtectedStorageEntry> entriesForSignal = new ArrayList<>(entriesToRemoveWithPayloadHash.size());
|
||||
entriesToRemoveWithPayloadHash.forEach(entryToRemoveWithPayloadHash -> {
|
||||
ByteArray hashOfPayload = entryToRemoveWithPayloadHash.getKey();
|
||||
ProtectedStorageEntry protectedStorageEntry = entryToRemoveWithPayloadHash.getValue();
|
||||
|
||||
map.remove(hashOfPayload);
|
||||
hashMapChangedListeners.forEach(e -> e.onRemoved(Collections.singletonList(protectedStorageEntry)));
|
||||
entriesForSignal.add(protectedStorageEntry);
|
||||
|
||||
ProtectedStoragePayload protectedStoragePayload = protectedStorageEntry.getProtectedStoragePayload();
|
||||
if (protectedStoragePayload instanceof PersistablePayload) {
|
||||
@ -669,6 +674,8 @@ public class P2PDataStorage implements MessageListener, ConnectionListener, Pers
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
hashMapChangedListeners.forEach(e -> e.onRemoved(entriesForSignal));
|
||||
}
|
||||
|
||||
private boolean hasSequenceNrIncreased(int newSequenceNumber, ByteArray hashOfData) {
|
||||
|
Loading…
Reference in New Issue
Block a user