mirror of
https://github.com/bisq-network/bisq.git
synced 2024-11-19 09:52:23 +01:00
Update PersistableNetworkPayloadStore
This commit is contained in:
parent
5a1cd0ee2c
commit
e2f0f61943
@ -22,16 +22,30 @@ import bisq.network.p2p.storage.payload.PersistableNetworkPayload;
|
||||
|
||||
import bisq.common.proto.persistable.PersistableEnvelope;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
|
||||
/**
|
||||
* Base class for store implementations using a map with a PersistableNetworkPayload
|
||||
* as the type of the map value.
|
||||
* Store for PersistableNetworkPayload map entries with it's data hash as key.
|
||||
*/
|
||||
public abstract class PersistableNetworkPayloadStore implements PersistableEnvelope {
|
||||
@Slf4j
|
||||
public abstract class PersistableNetworkPayloadStore<T extends PersistableNetworkPayload> implements PersistableEnvelope {
|
||||
@Getter
|
||||
public Map<P2PDataStorage.ByteArray, PersistableNetworkPayload> map = new ConcurrentHashMap<>();
|
||||
protected final Map<P2PDataStorage.ByteArray, PersistableNetworkPayload> map = new ConcurrentHashMap<>();
|
||||
|
||||
protected PersistableNetworkPayloadStore() {
|
||||
}
|
||||
|
||||
protected PersistableNetworkPayloadStore(Collection<T> collection) {
|
||||
collection.forEach(item -> map.put(new P2PDataStorage.ByteArray(item.getHash()), item));
|
||||
}
|
||||
|
||||
public boolean containsKey(P2PDataStorage.ByteArray hash) {
|
||||
return map.containsKey(hash);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user