mirror of
https://github.com/bisq-network/bisq.git
synced 2024-11-19 01:41:11 +01:00
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:
parent
35d9338615
commit
d3be8dd48b
@ -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);
|
||||
}
|
||||
}
|
@ -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<>();
|
||||
|
@ -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
|
||||
|
@ -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();
|
||||
|
@ -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<>();
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user