diff --git a/core/src/main/java/bisq/core/proto/persistable/CorePersistenceProtoResolver.java b/core/src/main/java/bisq/core/proto/persistable/CorePersistenceProtoResolver.java index 2e16d005e02..b38a015fbb1 100644 --- a/core/src/main/java/bisq/core/proto/persistable/CorePersistenceProtoResolver.java +++ b/core/src/main/java/bisq/core/proto/persistable/CorePersistenceProtoResolver.java @@ -43,7 +43,6 @@ import bisq.core.user.UserPayload; import bisq.network.p2p.peers.peerexchange.PeerList; -import bisq.network.p2p.storage.persistence.PersistableNetworkPayloadList; import bisq.network.p2p.storage.persistence.SequenceNumberMap; import bisq.common.config.Config; @@ -101,8 +100,6 @@ public PersistableEnvelope fromProto(protobuf.PersistableEnvelope proto) { this, new Storage<>(storageDir, this, corruptedDatabaseFilesHandler), btcWalletService.get()); - case TRADE_STATISTICS_LIST: - throw new ProtobufferRuntimeException("TRADE_STATISTICS_LIST is not used anymore"); case ARBITRATION_DISPUTE_LIST: return ArbitrationDisputeList.fromProto(proto.getArbitrationDisputeList(), this, @@ -123,8 +120,6 @@ public PersistableEnvelope fromProto(protobuf.PersistableEnvelope proto) { return NavigationPath.fromProto(proto.getNavigationPath()); case PAYMENT_ACCOUNT_LIST: return PaymentAccountList.fromProto(proto.getPaymentAccountList(), this); - case PERSISTABLE_NETWORK_PAYLOAD_LIST: - return PersistableNetworkPayloadList.fromProto(proto.getPersistableNetworkPayloadList(), this); case ACCOUNT_AGE_WITNESS_STORE: return AccountAgeWitnessStore.fromProto(proto.getAccountAgeWitnessStore()); case TRADE_STATISTICS2_STORE: diff --git a/p2p/src/main/java/bisq/network/p2p/P2PModule.java b/p2p/src/main/java/bisq/network/p2p/P2PModule.java index a0cf8370c38..61c63f1de02 100644 --- a/p2p/src/main/java/bisq/network/p2p/P2PModule.java +++ b/p2p/src/main/java/bisq/network/p2p/P2PModule.java @@ -28,7 +28,6 @@ import bisq.network.p2p.peers.peerexchange.PeerExchangeManager; import bisq.network.p2p.storage.P2PDataStorage; import bisq.network.p2p.storage.persistence.AppendOnlyDataStoreService; -import bisq.network.p2p.storage.persistence.PersistableNetworkPayloadListService; import bisq.network.p2p.storage.persistence.ProtectedDataStoreService; import bisq.network.p2p.storage.persistence.ResourceDataStoreService; @@ -62,7 +61,6 @@ protected void configure() { bind(P2PDataStorage.class).in(Singleton.class); bind(AppendOnlyDataStoreService.class).in(Singleton.class); bind(ProtectedDataStoreService.class).in(Singleton.class); - bind(PersistableNetworkPayloadListService.class).in(Singleton.class); bind(ResourceDataStoreService.class).in(Singleton.class); bind(RequestDataManager.class).in(Singleton.class); bind(PeerExchangeManager.class).in(Singleton.class); diff --git a/p2p/src/main/java/bisq/network/p2p/storage/persistence/AppendOnlyDataStoreService.java b/p2p/src/main/java/bisq/network/p2p/storage/persistence/AppendOnlyDataStoreService.java index 64ec0939b29..c7ea20c9438 100644 --- a/p2p/src/main/java/bisq/network/p2p/storage/persistence/AppendOnlyDataStoreService.java +++ b/p2p/src/main/java/bisq/network/p2p/storage/persistence/AppendOnlyDataStoreService.java @@ -38,20 +38,13 @@ public class AppendOnlyDataStoreService { private List> services = new ArrayList<>(); - // We do not add PersistableNetworkPayloadListService to the services list as it it deprecated and used only to - // transfer old persisted data to the new data structure. - @SuppressWarnings("deprecation") - private PersistableNetworkPayloadListService persistableNetworkPayloadListService; - /////////////////////////////////////////////////////////////////////////////////////////// // Constructor /////////////////////////////////////////////////////////////////////////////////////////// - @SuppressWarnings("deprecation") @Inject - public AppendOnlyDataStoreService(PersistableNetworkPayloadListService persistableNetworkPayloadListService) { - this.persistableNetworkPayloadListService = persistableNetworkPayloadListService; + public AppendOnlyDataStoreService() { } public void addService(MapStoreService service) { @@ -60,19 +53,6 @@ public void addService(MapStoreService service.readFromResources(postFix)); - - // transferDeprecatedDataStructure(); - } - - // Only needed for one time converting the old data store to the new ones. Can be removed after next release when we - // are sure that no issues occurred. - private void transferDeprecatedDataStructure() { - // We read the file if it exists in the db folder - persistableNetworkPayloadListService.readStore(); - // Transfer the content to the new services - persistableNetworkPayloadListService.getMap().forEach(this::put); - // We are done with the transfer, now let's remove the file - persistableNetworkPayloadListService.removeFile(); } public Map getMap() { diff --git a/p2p/src/main/java/bisq/network/p2p/storage/persistence/PersistableNetworkPayloadList.java b/p2p/src/main/java/bisq/network/p2p/storage/persistence/PersistableNetworkPayloadList.java deleted file mode 100644 index 50cb5d7b20d..00000000000 --- a/p2p/src/main/java/bisq/network/p2p/storage/persistence/PersistableNetworkPayloadList.java +++ /dev/null @@ -1,86 +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 . - */ - -package bisq.network.p2p.storage.persistence; - -import bisq.network.p2p.storage.P2PDataStorage; -import bisq.network.p2p.storage.payload.PersistableNetworkPayload; - -import bisq.common.proto.persistable.PersistenceProtoResolver; -import bisq.common.proto.persistable.ThreadedPersistableEnvelope; - -import com.google.protobuf.Message; - -import java.util.HashMap; -import java.util.Map; -import java.util.Set; -import java.util.concurrent.ConcurrentHashMap; -import java.util.stream.Collectors; - -import lombok.Getter; -import lombok.extern.slf4j.Slf4j; - -// That class wraps a map but is represented in PB as a list to reduce data size (no key). -// PB also does not support a byte array as key and would require some quirks to support such a map (using hex string -// would render our 20 byte keys to 40 bytes as HEX encoded). -// The class name should be map not list but we want to stick with the PB definition name and that cannot be changed -// without breaking backward compatibility. -// TODO at next hard fork we can rename the PB definition and class name. -@Deprecated -@Slf4j -public class PersistableNetworkPayloadList implements ThreadedPersistableEnvelope { - @Getter - private Map map = new ConcurrentHashMap<>(); - - PersistableNetworkPayloadList() { - } - - - /////////////////////////////////////////////////////////////////////////////////////////// - // PROTO BUFFER - /////////////////////////////////////////////////////////////////////////////////////////// - - private PersistableNetworkPayloadList(Map map) { - this.map.putAll(map); - } - - public Message toProtoMessage() { - // Protobuffer maps don't support bytes as key so we use a hex string - Set values = map.values().stream() - .map(PersistableNetworkPayload::toProtoMessage) - .collect(Collectors.toSet()); - return protobuf.PersistableEnvelope.newBuilder() - .setPersistableNetworkPayloadList(protobuf.PersistableNetworkPayloadList.newBuilder() - .addAllItems(values)) - .build(); - } - - public static PersistableNetworkPayloadList fromProto(protobuf.PersistableNetworkPayloadList proto, - PersistenceProtoResolver resolver) { - Map map = new HashMap<>(); - proto.getItemsList() - .forEach(e -> { - PersistableNetworkPayload payload = PersistableNetworkPayload.fromProto(e, resolver); - map.put(new P2PDataStorage.ByteArray(payload.getHash()), payload); - }); - return new PersistableNetworkPayloadList(map); - } - - public boolean containsKey(P2PDataStorage.ByteArray hash) { - return map.containsKey(hash); - } -} diff --git a/p2p/src/main/java/bisq/network/p2p/storage/persistence/PersistableNetworkPayloadListService.java b/p2p/src/main/java/bisq/network/p2p/storage/persistence/PersistableNetworkPayloadListService.java deleted file mode 100644 index d73f96bfcc5..00000000000 --- a/p2p/src/main/java/bisq/network/p2p/storage/persistence/PersistableNetworkPayloadListService.java +++ /dev/null @@ -1,126 +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 . - */ - -package bisq.network.p2p.storage.persistence; - -import bisq.network.p2p.storage.P2PDataStorage; -import bisq.network.p2p.storage.payload.PersistableNetworkPayload; - -import bisq.common.config.Config; -import bisq.common.storage.FileUtil; -import bisq.common.storage.Storage; - -import javax.inject.Named; - -import javax.inject.Inject; - -import java.nio.file.Paths; - -import java.io.File; -import java.io.IOException; - -import java.util.Map; - -import lombok.extern.slf4j.Slf4j; - -import static com.google.common.base.Preconditions.checkArgument; - -/** - * Not used anymore. We still need the class for supporting the transfer of th old data structure to the new. - * Can be removed at the next hard fork. - */ -@Deprecated -@Slf4j -public final class PersistableNetworkPayloadListService extends MapStoreService { - private static final String FILE_NAME = "PersistableNetworkPayloadMap"; - - - /////////////////////////////////////////////////////////////////////////////////////////// - // Constructor - /////////////////////////////////////////////////////////////////////////////////////////// - - @Inject - public PersistableNetworkPayloadListService(@Named(Config.STORAGE_DIR) File storageDir, - Storage persistableNetworkPayloadMapStorage) { - super(storageDir, persistableNetworkPayloadMapStorage); - } - - - /////////////////////////////////////////////////////////////////////////////////////////// - // API - /////////////////////////////////////////////////////////////////////////////////////////// - - public void removeFile() { - final File file = new File(Paths.get(absolutePathOfStorageDir, getFileName()).toString()); - if (file.exists()) - log.info("Remove deprecated file " + file.getAbsolutePath()); - try { - FileUtil.deleteFileIfExists(file); - } catch (IOException e) { - e.printStackTrace(); - log.error(e.toString()); - } - } - - @Override - public PersistableNetworkPayload putIfAbsent(P2PDataStorage.ByteArray hash, PersistableNetworkPayload payload) { - throw new RuntimeException("putIfAbsent must not be called on deprecated PersistableNetworkPayloadListService"); - } - - @Override - protected void persist() { - throw new RuntimeException("persist must not be called on deprecated PersistableNetworkPayloadListService"); - } - - @Override - public PersistableNetworkPayload remove(P2PDataStorage.ByteArray hash) { - throw new RuntimeException("remove must not be called on deprecated PersistableNetworkPayloadListService"); - } - - @Override - public boolean canHandle(PersistableNetworkPayload payload) { - throw new RuntimeException("isMyPayload must not be called on deprecated PersistableNetworkPayloadListService"); - } - - @Override - public String getFileName() { - return FILE_NAME; - } - - @Override - public Map getMap() { - return store.getMap(); - } - - - /////////////////////////////////////////////////////////////////////////////////////////// - // Protected - /////////////////////////////////////////////////////////////////////////////////////////// - - @Override - protected PersistableNetworkPayloadList createStore() { - return new PersistableNetworkPayloadList(); - } - - @Override - protected void readStore() { - super.readStore(); - checkArgument(store instanceof PersistableNetworkPayloadList, - "Store is not instance of TradeStatistics2Store. That can happen if the ProtoBuffer " + - "file got changed. We clear the data store and recreated it again."); - } -} diff --git a/p2p/src/test/java/bisq/network/p2p/storage/mocks/AppendOnlyDataStoreServiceFake.java b/p2p/src/test/java/bisq/network/p2p/storage/mocks/AppendOnlyDataStoreServiceFake.java index 4119ff1426c..155e4708be7 100644 --- a/p2p/src/test/java/bisq/network/p2p/storage/mocks/AppendOnlyDataStoreServiceFake.java +++ b/p2p/src/test/java/bisq/network/p2p/storage/mocks/AppendOnlyDataStoreServiceFake.java @@ -34,7 +34,6 @@ public class AppendOnlyDataStoreServiceFake extends AppendOnlyDataStoreService { private final Map map; public AppendOnlyDataStoreServiceFake() { - super(null); map = new HashMap<>(); } diff --git a/proto/src/main/proto/pb.proto b/proto/src/main/proto/pb.proto index e1cc8b39c4c..677cd9da685 100644 --- a/proto/src/main/proto/pb.proto +++ b/proto/src/main/proto/pb.proto @@ -1115,7 +1115,7 @@ message PersistableEnvelope { NavigationPath navigation_path = 5; TradableList tradable_list = 6; - TradeStatisticsList trade_statistics_list = 7 [deprecated = true]; // Was used in pre v0.6.0 version. Not used anymore. + // TradeStatisticsList trade_statistics_list = 7; // Was used in pre v0.6.0 version. Not used anymore. ArbitrationDisputeList arbitration_dispute_list = 8; PreferencesPayload preferences_payload = 9; @@ -1128,10 +1128,7 @@ message PersistableEnvelope { AccountAgeWitnessStore account_age_witness_store = 13; TradeStatistics2Store trade_statistics2_store = 14; - // we need to keep id 15 here otherwise the reading of the old data structure would not work anymore. - // can be removed after most people have updated as the reading of the PersistableNetworkPayloadList - // is not mandatory. - PersistableNetworkPayloadList persistable_network_payload_list = 15 [deprecated = true]; + // PersistableNetworkPayloadList persistable_network_payload_list = 15; // long deprecated & migration away from it is already done ProposalStore proposal_store = 16; TempProposalStore temp_proposal_store = 17; @@ -1178,11 +1175,6 @@ message PersistedEntryMap { map persisted_entry_map = 1; } -// deprecated. Not used anymore. -message PersistableNetworkPayloadList { - repeated PersistableNetworkPayload items = 1; -} - // We use a list not a hash map to save disc space. The hash can be calculated from the payload anyway message AccountAgeWitnessStore { repeated AccountAgeWitness items = 1; @@ -1239,11 +1231,6 @@ message TradableList { repeated Tradable tradable = 1; } -// deprecated Was used in pre v0.6.0 version. Not used anymore but leave it as it is used in PersistableEnvelope -message TradeStatisticsList { - repeated TradeStatistics trade_statistics = 1; -} - message Offer { enum State { PB_ERROR = 0;