Skip to content

Commit

Permalink
Merge pull request #4159 from stejbac/remove-unused-PersistableEnvelo…
Browse files Browse the repository at this point in the history
…pe-types

Remove PersistableNetworkPayloadList & TradeStatisticsList
  • Loading branch information
sqrrm authored May 11, 2020
2 parents 246d5ee + e5ed365 commit c07988f
Show file tree
Hide file tree
Showing 7 changed files with 3 additions and 256 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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,
Expand All @@ -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:
Expand Down
2 changes: 0 additions & 2 deletions p2p/src/main/java/bisq/network/p2p/P2PModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,20 +38,13 @@
public class AppendOnlyDataStoreService {
private List<MapStoreService<? extends PersistableEnvelope, PersistableNetworkPayload>> 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<? extends PersistableEnvelope, PersistableNetworkPayload> service) {
Expand All @@ -60,19 +53,6 @@ public void addService(MapStoreService<? extends PersistableEnvelope, Persistabl

public void readFromResources(String postFix) {
services.forEach(service -> 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<P2PDataStorage.ByteArray, PersistableNetworkPayload> getMap() {
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ public class AppendOnlyDataStoreServiceFake extends AppendOnlyDataStoreService {
private final Map<P2PDataStorage.ByteArray, PersistableNetworkPayload> map;

public AppendOnlyDataStoreServiceFake() {
super(null);
map = new HashMap<>();
}

Expand Down
17 changes: 2 additions & 15 deletions proto/src/main/proto/pb.proto
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -1178,11 +1175,6 @@ message PersistedEntryMap {
map<string, ProtectedStorageEntry> 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;
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit c07988f

Please sign in to comment.