mirror of
https://github.com/bisq-network/bisq.git
synced 2024-11-19 18:03:12 +01:00
Update AccountAgeWitnessStorage classes
This commit is contained in:
parent
d9a7aacf98
commit
8781c80fb0
@ -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<AccountAgeWitnessStore, PersistableNetworkPayload> {
|
||||
private static final String FILE_NAME = "AccountAgeWitnessStore";
|
||||
@ -46,14 +44,19 @@ public class AccountAgeWitnessStorageService extends MapStoreService<AccountAgeW
|
||||
|
||||
@Inject
|
||||
public AccountAgeWitnessStorageService(@Named(Config.STORAGE_DIR) File storageDir,
|
||||
Storage<AccountAgeWitnessStore> persistableNetworkPayloadMapStorage) {
|
||||
super(storageDir, persistableNetworkPayloadMapStorage);
|
||||
PersistenceManager<AccountAgeWitnessStore> 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<AccountAgeW
|
||||
protected AccountAgeWitnessStore createStore() {
|
||||
return new AccountAgeWitnessStore();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void readStore() {
|
||||
super.readStore();
|
||||
checkArgument(store instanceof AccountAgeWitnessStore,
|
||||
"Store is not instance of AccountAgeWitnessStore. That can happen if the ProtoBuffer " +
|
||||
"file got changed. We cleared the data store and recreated it again.");
|
||||
}
|
||||
}
|
||||
|
@ -17,7 +17,6 @@
|
||||
|
||||
package bisq.core.account.witness;
|
||||
|
||||
import bisq.network.p2p.storage.P2PDataStorage;
|
||||
import bisq.network.p2p.storage.persistence.PersistableNetworkPayloadStore;
|
||||
|
||||
import com.google.protobuf.Message;
|
||||
@ -34,7 +33,7 @@ import lombok.extern.slf4j.Slf4j;
|
||||
* definition and provide a hashMap for the domain access.
|
||||
*/
|
||||
@Slf4j
|
||||
public class AccountAgeWitnessStore extends PersistableNetworkPayloadStore {
|
||||
public class AccountAgeWitnessStore extends PersistableNetworkPayloadStore<AccountAgeWitness> {
|
||||
|
||||
AccountAgeWitnessStore() {
|
||||
}
|
||||
@ -45,7 +44,7 @@ public class AccountAgeWitnessStore extends PersistableNetworkPayloadStore {
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
private AccountAgeWitnessStore(List<AccountAgeWitness> 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);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user