mirror of
https://github.com/bisq-network/bisq.git
synced 2025-02-23 15:00:30 +01:00
Merge pull request #3150 from wiz/update-datastore
Update data storage on expired data removal
This commit is contained in:
commit
cbbd1a0bf8
1 changed files with 18 additions and 11 deletions
|
@ -201,8 +201,10 @@ public class P2PDataStorage implements MessageListener, ConnectionListener, Pers
|
||||||
// Batch processing can cause performance issues, so we give listeners a chance to deal with it by notifying
|
// Batch processing can cause performance issues, so we give listeners a chance to deal with it by notifying
|
||||||
// about start and end of iteration.
|
// about start and end of iteration.
|
||||||
hashMapChangedListeners.forEach(HashMapChangedListener::onBatchRemoveExpiredDataStarted);
|
hashMapChangedListeners.forEach(HashMapChangedListener::onBatchRemoveExpiredDataStarted);
|
||||||
toRemoveSet.forEach(protectedDataToRemove -> hashMapChangedListeners.forEach(
|
toRemoveSet.forEach(protectedStorageEntry -> {
|
||||||
listener -> listener.onRemoved(protectedDataToRemove)));
|
hashMapChangedListeners.forEach(l -> l.onRemoved(protectedStorageEntry));
|
||||||
|
removeFromProtectedDataStore(protectedStorageEntry);
|
||||||
|
});
|
||||||
hashMapChangedListeners.forEach(HashMapChangedListener::onBatchRemoveExpiredDataCompleted);
|
hashMapChangedListeners.forEach(HashMapChangedListener::onBatchRemoveExpiredDataCompleted);
|
||||||
|
|
||||||
if (sequenceNumberMap.size() > 1000)
|
if (sequenceNumberMap.size() > 1000)
|
||||||
|
@ -483,6 +485,15 @@ public class P2PDataStorage implements MessageListener, ConnectionListener, Pers
|
||||||
|
|
||||||
broadcast(new RemoveDataMessage(protectedStorageEntry), sender, null, isDataOwner);
|
broadcast(new RemoveDataMessage(protectedStorageEntry), sender, null, isDataOwner);
|
||||||
|
|
||||||
|
removeFromProtectedDataStore(protectedStorageEntry);
|
||||||
|
} else {
|
||||||
|
log.debug("remove failed");
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void removeFromProtectedDataStore(ProtectedStorageEntry protectedStorageEntry) {
|
||||||
|
ProtectedStoragePayload protectedStoragePayload = protectedStorageEntry.getProtectedStoragePayload();
|
||||||
if (protectedStoragePayload instanceof PersistablePayload) {
|
if (protectedStoragePayload instanceof PersistablePayload) {
|
||||||
ByteArray compactHash = getCompactHashAsByteArray(protectedStoragePayload);
|
ByteArray compactHash = getCompactHashAsByteArray(protectedStoragePayload);
|
||||||
ProtectedStorageEntry previous = protectedDataStoreService.remove(compactHash, protectedStorageEntry);
|
ProtectedStorageEntry previous = protectedDataStoreService.remove(compactHash, protectedStorageEntry);
|
||||||
|
@ -492,10 +503,6 @@ public class P2PDataStorage implements MessageListener, ConnectionListener, Pers
|
||||||
log.info("We cannot remove the protectedStorageEntry from the persistedEntryMap as it does not exist.");
|
log.info("We cannot remove the protectedStorageEntry from the persistedEntryMap as it does not exist.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
log.debug("remove failed");
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("UnusedReturnValue")
|
@SuppressWarnings("UnusedReturnValue")
|
||||||
|
|
Loading…
Add table
Reference in a new issue