mirror of
https://github.com/bisq-network/bisq.git
synced 2025-02-24 15:10:44 +01:00
Update SignedWitness classes
This commit is contained in:
parent
dc77b5cab8
commit
d9a7aacf98
2 changed files with 11 additions and 21 deletions
|
@ -22,10 +22,10 @@ import bisq.network.p2p.storage.payload.PersistableNetworkPayload;
|
||||||
import bisq.network.p2p.storage.persistence.MapStoreService;
|
import bisq.network.p2p.storage.persistence.MapStoreService;
|
||||||
|
|
||||||
import bisq.common.config.Config;
|
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.Inject;
|
||||||
|
import javax.inject.Named;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
|
||||||
|
@ -33,8 +33,6 @@ import java.util.Map;
|
||||||
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkArgument;
|
|
||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public class SignedWitnessStorageService extends MapStoreService<SignedWitnessStore, PersistableNetworkPayload> {
|
public class SignedWitnessStorageService extends MapStoreService<SignedWitnessStore, PersistableNetworkPayload> {
|
||||||
private static final String FILE_NAME = "SignedWitnessStore";
|
private static final String FILE_NAME = "SignedWitnessStore";
|
||||||
|
@ -46,14 +44,19 @@ public class SignedWitnessStorageService extends MapStoreService<SignedWitnessSt
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public SignedWitnessStorageService(@Named(Config.STORAGE_DIR) File storageDir,
|
public SignedWitnessStorageService(@Named(Config.STORAGE_DIR) File storageDir,
|
||||||
Storage<SignedWitnessStore> persistableNetworkPayloadMapStorage) {
|
PersistenceManager<SignedWitnessStore> persistenceManager) {
|
||||||
super(storageDir, persistableNetworkPayloadMapStorage);
|
super(storageDir, persistenceManager);
|
||||||
}
|
}
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// API
|
// API
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void initializePersistenceManager() {
|
||||||
|
persistenceManager.initialize(store, PersistenceManager.Priority.LOW);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getFileName() {
|
public String getFileName() {
|
||||||
return FILE_NAME;
|
return FILE_NAME;
|
||||||
|
@ -78,12 +81,4 @@ public class SignedWitnessStorageService extends MapStoreService<SignedWitnessSt
|
||||||
protected SignedWitnessStore createStore() {
|
protected SignedWitnessStore createStore() {
|
||||||
return new SignedWitnessStore();
|
return new SignedWitnessStore();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void readStore() {
|
|
||||||
super.readStore();
|
|
||||||
checkArgument(store instanceof SignedWitnessStore,
|
|
||||||
"Store is not instance of SignedWitnessStore. That can happen if the ProtoBuffer " +
|
|
||||||
"file got changed. We cleared the data store and recreated it again.");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,7 +18,6 @@
|
||||||
package bisq.core.account.sign;
|
package bisq.core.account.sign;
|
||||||
|
|
||||||
|
|
||||||
import bisq.network.p2p.storage.P2PDataStorage;
|
|
||||||
import bisq.network.p2p.storage.persistence.PersistableNetworkPayloadStore;
|
import bisq.network.p2p.storage.persistence.PersistableNetworkPayloadStore;
|
||||||
|
|
||||||
import com.google.protobuf.Message;
|
import com.google.protobuf.Message;
|
||||||
|
@ -35,7 +34,7 @@ import lombok.extern.slf4j.Slf4j;
|
||||||
* definition and provide a hashMap for the domain access.
|
* definition and provide a hashMap for the domain access.
|
||||||
*/
|
*/
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public class SignedWitnessStore extends PersistableNetworkPayloadStore {
|
public class SignedWitnessStore extends PersistableNetworkPayloadStore<SignedWitness> {
|
||||||
|
|
||||||
SignedWitnessStore() {
|
SignedWitnessStore() {
|
||||||
}
|
}
|
||||||
|
@ -46,7 +45,7 @@ public class SignedWitnessStore extends PersistableNetworkPayloadStore {
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
private SignedWitnessStore(List<SignedWitness> list) {
|
private SignedWitnessStore(List<SignedWitness> list) {
|
||||||
list.forEach(item -> map.put(new P2PDataStorage.ByteArray(item.getHash()), item));
|
super(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Message toProtoMessage() {
|
public Message toProtoMessage() {
|
||||||
|
@ -68,8 +67,4 @@ public class SignedWitnessStore extends PersistableNetworkPayloadStore {
|
||||||
.map(SignedWitness::fromProto).collect(Collectors.toList());
|
.map(SignedWitness::fromProto).collect(Collectors.toList());
|
||||||
return new SignedWitnessStore(list);
|
return new SignedWitnessStore(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean containsKey(P2PDataStorage.ByteArray hash) {
|
|
||||||
return map.containsKey(hash);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue