Remove ThreadedPersistableEnvelope and use PersistableEnvelope instead

We will not need threading support anymore once we use the new persistenceManager as serialisation is done on the userThread.
This commit is contained in:
chimp1984 2020-10-01 17:12:31 -05:00
parent d3be8dd48b
commit 3a348d5a0f
No known key found for this signature in database
GPG Key ID: 9801B4EC591F90E3
5 changed files with 8 additions and 52 deletions

View File

@ -1,44 +0,0 @@
/*
* This file is part of Bisq.
*
* Bisq is free software: you can redistribute it and/or modify it
* under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or (at
* your option) any later version.
*
* Bisq is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public
* License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with Bisq. If not, see <http://www.gnu.org/licenses/>.
*/
package bisq.common.proto.persistable;
import com.google.protobuf.Message;
/**
* Interface for the outer envelope object persisted to disk, where its serialization
* during persistence takes place on a separate thread (for performance).
* <p>
* To make the serialization thread-safe, all modifications of the object must be
* synchronized with it. This may be achieved by wrapping such modifications with the
* provided {@link ThreadedPersistableEnvelope#modifySynchronized(Runnable)} method.
*/
public interface ThreadedPersistableEnvelope extends PersistableEnvelope {
@Override
default Message toPersistableMessage() {
synchronized (this) {
return toProtoMessage();
}
}
default void modifySynchronized(Runnable modifyTask) {
synchronized (this) {
modifyTask.run();
}
}
}

View File

@ -21,7 +21,7 @@ import bisq.network.p2p.storage.P2PDataStorage;
import bisq.network.p2p.storage.payload.ProtectedStorageEntry;
import bisq.common.proto.network.NetworkProtoResolver;
import bisq.common.proto.persistable.ThreadedPersistableEnvelope;
import bisq.common.proto.persistable.PersistableEnvelope;
import com.google.protobuf.Message;
@ -42,7 +42,7 @@ import lombok.extern.slf4j.Slf4j;
* definition and provide a hashMap for the domain access.
*/
@Slf4j
public class TempProposalStore implements ThreadedPersistableEnvelope {
public class TempProposalStore implements PersistableEnvelope {
@Getter
private Map<P2PDataStorage.ByteArray, ProtectedStorageEntry> map = new ConcurrentHashMap<>();

View File

@ -20,7 +20,7 @@ package bisq.core.dao.state;
import bisq.core.dao.monitoring.model.DaoStateHash;
import bisq.core.dao.state.model.DaoState;
import bisq.common.proto.persistable.ThreadedPersistableEnvelope;
import bisq.common.proto.persistable.PersistableEnvelope;
import com.google.protobuf.Message;
@ -35,7 +35,7 @@ import static com.google.common.base.Preconditions.checkNotNull;
@Slf4j
public class DaoStateStore implements ThreadedPersistableEnvelope {
public class DaoStateStore implements PersistableEnvelope {
// DaoState is always a clone and must not be used for read access beside initial read from disc when we apply
// the snapshot!
@Getter

View File

@ -20,7 +20,7 @@ package bisq.network.p2p.storage.persistence;
import bisq.network.p2p.storage.P2PDataStorage;
import bisq.network.p2p.storage.payload.PersistableNetworkPayload;
import bisq.common.proto.persistable.ThreadedPersistableEnvelope;
import bisq.common.proto.persistable.PersistableEnvelope;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
@ -31,7 +31,7 @@ import lombok.Getter;
* Base class for store implementations using a map with a PersistableNetworkPayload
* as the type of the map value.
*/
public abstract class PersistableNetworkPayloadStore implements ThreadedPersistableEnvelope {
public abstract class PersistableNetworkPayloadStore implements PersistableEnvelope {
@Getter
public Map<P2PDataStorage.ByteArray, PersistableNetworkPayload> map = new ConcurrentHashMap<>();
}

View File

@ -19,7 +19,7 @@ package bisq.network.p2p.storage.persistence;
import bisq.network.p2p.storage.P2PDataStorage;
import bisq.common.proto.persistable.ThreadedPersistableEnvelope;
import bisq.common.proto.persistable.PersistableEnvelope;
import java.util.HashMap;
import java.util.Map;
@ -34,7 +34,7 @@ import lombok.Setter;
* in protobuffer the map construct can't be anything, so the straightforward mapping was not possible.
* Hence this Persistable class.
*/
public class SequenceNumberMap implements ThreadedPersistableEnvelope {
public class SequenceNumberMap implements PersistableEnvelope {
@Getter
@Setter
private Map<P2PDataStorage.ByteArray, P2PDataStorage.MapValue> map = new ConcurrentHashMap<>();