Remove UserThreadMappedPersistableEnvelope 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:09:50 -05:00
parent 35d9338615
commit d3be8dd48b
No known key found for this signature in database
GPG Key ID: 9801B4EC591F90E3
6 changed files with 9 additions and 54 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 bisq.common.UserThread;
import com.google.protobuf.Message;
import com.google.common.util.concurrent.Futures;
import java.util.concurrent.FutureTask;
/**
* Interface for the outer envelope object persisted to disk, where its serialization
* during persistence is forced to take place on the user thread.
* <p>
* To avoid jitter, this should be only be used for small, safely critical stores. Larger
* or frequently written stores should either implement {@link PersistableEnvelope}
* directly (where thread-safety isn't needed) or use {@link ThreadedPersistableEnvelope}.
*/
public interface UserThreadMappedPersistableEnvelope extends PersistableEnvelope {
@Override
default Message toPersistableMessage() {
FutureTask<Message> toProtoOnUserThread = new FutureTask<>(this::toProtoMessage);
UserThread.execute(toProtoOnUserThread);
return Futures.getUnchecked(toProtoOnUserThread);
}
}

View File

@ -18,8 +18,8 @@
package bisq.core.btc.model;
import bisq.common.config.Config;
import bisq.common.proto.persistable.PersistableEnvelope;
import bisq.common.proto.persistable.PersistedDataHost;
import bisq.common.proto.persistable.UserThreadMappedPersistableEnvelope;
import bisq.common.storage.Storage;
import com.google.protobuf.Message;
@ -50,7 +50,7 @@ import lombok.extern.slf4j.Slf4j;
*/
@ToString
@Slf4j
public final class AddressEntryList implements UserThreadMappedPersistableEnvelope, PersistedDataHost {
public final class AddressEntryList implements PersistableEnvelope, PersistedDataHost {
transient private Storage<AddressEntryList> storage;
transient private Wallet wallet;
private final Set<AddressEntry> entrySet = new CopyOnWriteArraySet<>();

View File

@ -19,7 +19,6 @@ package bisq.core.support.dispute;
import bisq.common.proto.persistable.PersistableEnvelope;
import bisq.common.proto.persistable.PersistedDataHost;
import bisq.common.proto.persistable.UserThreadMappedPersistableEnvelope;
import bisq.common.storage.Storage;
import javafx.collections.FXCollections;
@ -40,7 +39,7 @@ import lombok.extern.slf4j.Slf4j;
* Calls to the List are delegated because this class intercepts the add/remove calls so changes
* can be saved to disc.
*/
public abstract class DisputeList<T extends PersistableEnvelope> implements UserThreadMappedPersistableEnvelope, PersistedDataHost {
public abstract class DisputeList<T extends PersistableEnvelope> implements PersistableEnvelope, PersistedDataHost {
transient protected final Storage<T> storage;
@Getter

View File

@ -23,7 +23,7 @@ import bisq.core.proto.CoreProtoResolver;
import bisq.common.proto.ProtoUtil;
import bisq.common.proto.ProtobufferRuntimeException;
import bisq.common.proto.persistable.UserThreadMappedPersistableEnvelope;
import bisq.common.proto.persistable.PersistableEnvelope;
import bisq.common.storage.Storage;
import com.google.protobuf.Message;
@ -41,7 +41,7 @@ import lombok.Getter;
import lombok.extern.slf4j.Slf4j;
@Slf4j
public final class TradableList<T extends Tradable> implements UserThreadMappedPersistableEnvelope {
public final class TradableList<T extends Tradable> implements PersistableEnvelope {
transient final private Storage<TradableList<T>> storage;
@Getter
private final ObservableList<T> list = FXCollections.observableArrayList();

View File

@ -25,7 +25,7 @@ import bisq.core.payment.PaymentAccount;
import bisq.core.proto.CoreProtoResolver;
import bisq.common.proto.ProtoUtil;
import bisq.common.proto.persistable.UserThreadMappedPersistableEnvelope;
import bisq.common.proto.persistable.PersistableEnvelope;
import com.google.protobuf.Message;
@ -49,7 +49,7 @@ import static bisq.core.btc.wallet.Restrictions.getDefaultBuyerSecurityDepositAs
@Slf4j
@Data
@AllArgsConstructor
public final class PreferencesPayload implements UserThreadMappedPersistableEnvelope {
public final class PreferencesPayload implements PersistableEnvelope {
private String userLanguage;
private Country userCountry;
private List<FiatCurrency> fiatCurrencies = new ArrayList<>();

View File

@ -28,7 +28,7 @@ import bisq.core.support.dispute.mediation.mediator.Mediator;
import bisq.core.support.dispute.refund.refundagent.RefundAgent;
import bisq.common.proto.ProtoUtil;
import bisq.common.proto.persistable.UserThreadMappedPersistableEnvelope;
import bisq.common.proto.persistable.PersistableEnvelope;
import java.util.ArrayList;
import java.util.HashSet;
@ -46,7 +46,7 @@ import javax.annotation.Nullable;
@Slf4j
@Data
@AllArgsConstructor
public class UserPayload implements UserThreadMappedPersistableEnvelope {
public class UserPayload implements PersistableEnvelope {
@Nullable
private String accountId;
@Nullable