Skip to content

Commit

Permalink
Restore type hierarchy of MeritList & VoteWithProposalTxIdList
Browse files Browse the repository at this point in the history
Provide UserThreadMappedPersistableList subclass for persistable lists
which need to implement UserThreadMappedPersistableEnvelope, instead of
putting the interface on the base class.

Make the (non-storage) classes MeritList and VoteWithProposalTxIdList
keep the original PersistableList superclass, deriving the remaining
subclasses of PersistableList from the new class instead. In this way,
further persistence-related changes are less likely to inadvertently
alter the behaviour of those two consensus-critical classes.

Removing the superfluous PersistableEnvelope interface from the two
classes (via the base class) will be done in a separate PR.
  • Loading branch information
stejbac committed Mar 22, 2020
1 parent 91fa073 commit 9ab649e
Show file tree
Hide file tree
Showing 10 changed files with 48 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
import lombok.experimental.Delegate;

@EqualsAndHashCode
public class PersistableList<T extends PersistablePayload> implements UserThreadMappedPersistableEnvelope, Iterable<T> {
public class PersistableList<T extends PersistablePayload> implements PersistableEnvelope, Iterable<T> {
@Delegate(excludes = ExcludesDelegateMethods.class)
@Getter
@Setter
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
* 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 java.util.List;

public class UserThreadMappedPersistableList<T extends PersistablePayload> extends PersistableList<T>
implements UserThreadMappedPersistableEnvelope {

public UserThreadMappedPersistableList(List<T> list) {
super(list);
}

public UserThreadMappedPersistableList() {
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

import bisq.core.dao.governance.ConsensusCritical;

import bisq.common.proto.persistable.PersistableList;
import bisq.common.proto.persistable.UserThreadMappedPersistableList;

import com.google.protobuf.Message;

Expand All @@ -33,7 +33,7 @@
* List of my own blind votes. Blind votes received from other voters are stored in the BlindVoteStore.
*/
@EqualsAndHashCode(callSuper = true)
public class MyBlindVoteList extends PersistableList<BlindVote> implements ConsensusCritical {
public class MyBlindVoteList extends UserThreadMappedPersistableList<BlindVote> implements ConsensusCritical {

MyBlindVoteList() {
super();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

package bisq.core.dao.governance.bond.reputation;

import bisq.common.proto.persistable.PersistableList;
import bisq.common.proto.persistable.UserThreadMappedPersistableList;

import java.util.ArrayList;
import java.util.List;
Expand All @@ -29,7 +29,7 @@
* PersistableEnvelope wrapper for list of MyReputations.
*/
@EqualsAndHashCode(callSuper = true)
public class MyReputationList extends PersistableList<MyReputation> {
public class MyReputationList extends UserThreadMappedPersistableList<MyReputation> {

private MyReputationList(List<MyReputation> list) {
super(list);
Expand Down Expand Up @@ -69,4 +69,3 @@ public String toString() {
.collect(Collectors.toList());
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

package bisq.core.dao.governance.myvote;

import bisq.common.proto.persistable.PersistableList;
import bisq.common.proto.persistable.UserThreadMappedPersistableList;

import com.google.protobuf.Message;

Expand All @@ -28,7 +28,7 @@
import lombok.EqualsAndHashCode;

@EqualsAndHashCode(callSuper = true)
public class MyVoteList extends PersistableList<MyVote> {
public class MyVoteList extends UserThreadMappedPersistableList<MyVote> {

MyVoteList() {
super();
Expand Down Expand Up @@ -65,4 +65,3 @@ public String toString() {
.collect(Collectors.toList());
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

package bisq.core.dao.governance.proofofburn;

import bisq.common.proto.persistable.PersistableList;
import bisq.common.proto.persistable.UserThreadMappedPersistableList;

import java.util.ArrayList;
import java.util.List;
Expand All @@ -29,7 +29,7 @@
* PersistableEnvelope wrapper for list of MyProofOfBurn objects.
*/
@EqualsAndHashCode(callSuper = true)
public class MyProofOfBurnList extends PersistableList<MyProofOfBurn> {
public class MyProofOfBurnList extends UserThreadMappedPersistableList<MyProofOfBurn> {

private MyProofOfBurnList(List<MyProofOfBurn> list) {
super(list);
Expand Down Expand Up @@ -69,4 +69,3 @@ public String toString() {
.collect(Collectors.toList());
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import bisq.core.dao.governance.ConsensusCritical;
import bisq.core.dao.state.model.governance.Proposal;

import bisq.common.proto.persistable.PersistableList;
import bisq.common.proto.persistable.UserThreadMappedPersistableList;

import java.util.ArrayList;
import java.util.List;
Expand All @@ -32,7 +32,7 @@
* PersistableEnvelope wrapper for list of proposals. Used in vote consensus, so changes can break consensus!
*/
@EqualsAndHashCode(callSuper = true)
public class MyProposalList extends PersistableList<Proposal> implements ConsensusCritical {
public class MyProposalList extends UserThreadMappedPersistableList<Proposal> implements ConsensusCritical {

public MyProposalList(List<Proposal> list) {
super(list);
Expand Down Expand Up @@ -72,4 +72,3 @@ public String toString() {
.collect(Collectors.toList());
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import bisq.core.dao.governance.ConsensusCritical;
import bisq.core.dao.state.model.ImmutableDaoStateModel;

import bisq.common.proto.persistable.PersistableList;
import bisq.common.proto.persistable.UserThreadMappedPersistableList;

import java.util.ArrayList;
import java.util.List;
Expand All @@ -35,7 +35,7 @@
*/
@Immutable
@EqualsAndHashCode(callSuper = true)
public class BallotList extends PersistableList<Ballot> implements ConsensusCritical, ImmutableDaoStateModel {
public class BallotList extends UserThreadMappedPersistableList<Ballot> implements ConsensusCritical, ImmutableDaoStateModel {

public BallotList(List<Ballot> list) {
super(list);
Expand Down Expand Up @@ -75,4 +75,3 @@ public String toString() {
.collect(Collectors.toList());
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

package bisq.core.dao.state.unconfirmed;

import bisq.common.proto.persistable.PersistableList;
import bisq.common.proto.persistable.UserThreadMappedPersistableList;

import com.google.protobuf.Message;

Expand All @@ -28,7 +28,7 @@
import lombok.EqualsAndHashCode;

@EqualsAndHashCode(callSuper = true)
public class UnconfirmedBsqChangeOutputList extends PersistableList<UnconfirmedTxOutput> {
public class UnconfirmedBsqChangeOutputList extends UserThreadMappedPersistableList<UnconfirmedTxOutput> {

UnconfirmedBsqChangeOutputList() {
super();
Expand Down
4 changes: 2 additions & 2 deletions core/src/main/java/bisq/core/payment/PaymentAccountList.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

import bisq.core.proto.CoreProtoResolver;

import bisq.common.proto.persistable.PersistableList;
import bisq.common.proto.persistable.UserThreadMappedPersistableList;

import com.google.protobuf.Message;

Expand All @@ -30,7 +30,7 @@
import lombok.EqualsAndHashCode;

@EqualsAndHashCode(callSuper = true)
public class PaymentAccountList extends PersistableList<PaymentAccount> {
public class PaymentAccountList extends UserThreadMappedPersistableList<PaymentAccount> {

public PaymentAccountList(List<PaymentAccount> list) {
super(list);
Expand Down

0 comments on commit 9ab649e

Please sign in to comment.