From 8781c80fb03aba6678a0ac4d67ba5848856f1db2 Mon Sep 17 00:00:00 2001 From: chimp1984 Date: Thu, 1 Oct 2020 17:40:38 -0500 Subject: [PATCH] Update AccountAgeWitnessStorage classes --- .../AccountAgeWitnessStorageService.java | 23 ++++++++----------- .../witness/AccountAgeWitnessStore.java | 9 ++------ 2 files changed, 11 insertions(+), 21 deletions(-) diff --git a/core/src/main/java/bisq/core/account/witness/AccountAgeWitnessStorageService.java b/core/src/main/java/bisq/core/account/witness/AccountAgeWitnessStorageService.java index bc261e7efe..8144dc4d48 100644 --- a/core/src/main/java/bisq/core/account/witness/AccountAgeWitnessStorageService.java +++ b/core/src/main/java/bisq/core/account/witness/AccountAgeWitnessStorageService.java @@ -22,10 +22,10 @@ import bisq.network.p2p.storage.payload.PersistableNetworkPayload; import bisq.network.p2p.storage.persistence.MapStoreService; import bisq.common.config.Config; -import bisq.common.storage.Storage; +import bisq.common.persistence.PersistenceManager; -import javax.inject.Named; import javax.inject.Inject; +import javax.inject.Named; import java.io.File; @@ -33,8 +33,6 @@ import java.util.Map; import lombok.extern.slf4j.Slf4j; -import static com.google.common.base.Preconditions.checkArgument; - @Slf4j public class AccountAgeWitnessStorageService extends MapStoreService { private static final String FILE_NAME = "AccountAgeWitnessStore"; @@ -46,14 +44,19 @@ public class AccountAgeWitnessStorageService extends MapStoreService persistableNetworkPayloadMapStorage) { - super(storageDir, persistableNetworkPayloadMapStorage); + PersistenceManager persistenceManager) { + super(storageDir, persistenceManager); } /////////////////////////////////////////////////////////////////////////////////////////// // API /////////////////////////////////////////////////////////////////////////////////////////// + @Override + protected void initializePersistenceManager() { + persistenceManager.initialize(store, PersistenceManager.Priority.LOW); + } + @Override public String getFileName() { return FILE_NAME; @@ -78,12 +81,4 @@ public class AccountAgeWitnessStorageService extends MapStoreService { AccountAgeWitnessStore() { } @@ -45,7 +44,7 @@ public class AccountAgeWitnessStore extends PersistableNetworkPayloadStore { /////////////////////////////////////////////////////////////////////////////////////////// private AccountAgeWitnessStore(List list) { - list.forEach(item -> map.put(new P2PDataStorage.ByteArray(item.getHash()), item)); + super(list); } public Message toProtoMessage() { @@ -67,8 +66,4 @@ public class AccountAgeWitnessStore extends PersistableNetworkPayloadStore { .map(AccountAgeWitness::fromProto).collect(Collectors.toList()); return new AccountAgeWitnessStore(list); } - - public boolean containsKey(P2PDataStorage.ByteArray hash) { - return map.containsKey(hash); - } }