From 94944393cf1f19a4f00c853627ba6f0ed31206bf Mon Sep 17 00:00:00 2001 From: chimp1984 Date: Thu, 1 Oct 2020 17:30:03 -0500 Subject: [PATCH] Use PersistenceManager in HistoricalDataStoreService --- .../HistoricalDataStoreService.java | 25 ++++++++++--------- 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/p2p/src/main/java/bisq/network/p2p/storage/persistence/HistoricalDataStoreService.java b/p2p/src/main/java/bisq/network/p2p/storage/persistence/HistoricalDataStoreService.java index 5f1346f20c..3c92ca706f 100644 --- a/p2p/src/main/java/bisq/network/p2p/storage/persistence/HistoricalDataStoreService.java +++ b/p2p/src/main/java/bisq/network/p2p/storage/persistence/HistoricalDataStoreService.java @@ -21,7 +21,7 @@ import bisq.network.p2p.storage.P2PDataStorage; import bisq.network.p2p.storage.payload.PersistableNetworkPayload; import bisq.common.app.Version; -import bisq.common.storage.Storage; +import bisq.common.persistence.PersistenceManager; import com.google.common.collect.ImmutableMap; @@ -39,8 +39,8 @@ import lombok.extern.slf4j.Slf4j; * request so the responding (seed)node can figure out if we miss any of the historical data. */ @Slf4j -public abstract class HistoricalDataStoreService extends MapStoreService { - private ImmutableMap storesByVersion; +public abstract class HistoricalDataStoreService> extends MapStoreService { + private ImmutableMap> storesByVersion; // Cache to avoid that we have to recreate the historical data at each request private ImmutableMap allHistoricalPayloads; @@ -49,8 +49,8 @@ public abstract class HistoricalDataStoreService storage) { - super(storageDir, storage); + public HistoricalDataStoreService(File storageDir, PersistenceManager persistenceManager) { + super(storageDir, persistenceManager); } @@ -126,7 +126,7 @@ public abstract class HistoricalDataStoreService allHistoricalPayloadsBuilder = ImmutableMap.builder(); - ImmutableMap.Builder storesByVersionBuilder = ImmutableMap.builder(); + ImmutableMap.Builder> storesByVersionBuilder = ImmutableMap.builder(); Version.HISTORY.forEach(version -> readHistoricalStoreFromResources(version, postFix, allHistoricalPayloadsBuilder, storesByVersionBuilder)); @@ -168,12 +168,12 @@ public abstract class HistoricalDataStoreService allHistoricalDataBuilder, - ImmutableMap.Builder storesByVersionBuilder) { + ImmutableMap.Builder> storesByVersionBuilder) { String fileName = getFileName() + "_" + version; boolean wasCreatedFromResources = makeFileFromResourceFile(fileName, postFix); // If resource file does not exist we return null. We do not create a new store as it would never get filled. - PersistableNetworkPayloadStore historicalStore = storage.getPersisted(fileName); + PersistableNetworkPayloadStore historicalStore = persistenceManager.getPersisted(fileName); if (historicalStore == null) { log.warn("Resource file with file name {} does not exits.", fileName); return; @@ -187,7 +187,8 @@ public abstract class HistoricalDataStoreService historicalStore, + String version) { int preLive = getMapOfLiveData().size(); getMapOfLiveData().keySet().removeAll(historicalStore.getMap().keySet()); int postLive = getMapOfLiveData().size(); @@ -198,7 +199,7 @@ public abstract class HistoricalDataStoreService