mirror of
https://github.com/bisq-network/bisq.git
synced 2024-11-19 18:03:12 +01:00
Merge pull request #2670 from ManfredKarrer/add-new-filter-option
Add filter for min required version for DAO
This commit is contained in:
commit
2f3dd40623
@ -528,6 +528,7 @@ message Filter {
|
||||
bool prevent_public_btc_network = 12;
|
||||
repeated string btc_nodes = 13;
|
||||
bool disable_dao = 14;
|
||||
string disable_dao_below_version = 15;
|
||||
}
|
||||
|
||||
// not used anymore from v0.6 on. But leave it for receiving TradeStatistics objects from older
|
||||
|
@ -21,10 +21,16 @@ import bisq.core.dao.exceptions.DaoDisabledException;
|
||||
import bisq.core.filter.Filter;
|
||||
import bisq.core.filter.FilterManager;
|
||||
|
||||
import bisq.common.app.Version;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
@Slf4j
|
||||
public class DaoKillSwitch implements DaoSetupService {
|
||||
private static DaoKillSwitch INSTANCE;
|
||||
private final FilterManager filterManager;
|
||||
@ -49,8 +55,19 @@ public class DaoKillSwitch implements DaoSetupService {
|
||||
applyFilter(filterManager.getFilter());
|
||||
}
|
||||
|
||||
private void applyFilter(Filter filter) {
|
||||
daoDisabled = filter != null && filter.isDisableDao();
|
||||
private void applyFilter(@Nullable Filter filter) {
|
||||
if (filter == null) {
|
||||
daoDisabled = false;
|
||||
return;
|
||||
}
|
||||
|
||||
boolean requireUpdateToNewVersion = false;
|
||||
String disableDaoBelowVersion = filter.getDisableDaoBelowVersion();
|
||||
if (disableDaoBelowVersion != null && !disableDaoBelowVersion.isEmpty()) {
|
||||
requireUpdateToNewVersion = Version.isNewVersion(disableDaoBelowVersion);
|
||||
}
|
||||
|
||||
daoDisabled = requireUpdateToNewVersion || filter.isDisableDao();
|
||||
}
|
||||
|
||||
public static void assertDaoIsNotDisabled() {
|
||||
|
@ -90,6 +90,10 @@ public final class Filter implements ProtectedStoragePayload, ExpirablePayload {
|
||||
// added in v0.9.4
|
||||
private final boolean disableDao;
|
||||
|
||||
// added in v0.9.8
|
||||
@Nullable
|
||||
private final String disableDaoBelowVersion;
|
||||
|
||||
public Filter(List<String> bannedOfferIds,
|
||||
List<String> bannedNodeAddress,
|
||||
List<PaymentAccountFilter> bannedPaymentAccounts,
|
||||
@ -100,7 +104,8 @@ public final class Filter implements ProtectedStoragePayload, ExpirablePayload {
|
||||
@Nullable List<String> priceRelayNodes,
|
||||
boolean preventPublicBtcNetwork,
|
||||
@Nullable List<String> btcNodes,
|
||||
boolean disableDao) {
|
||||
boolean disableDao,
|
||||
@Nullable String disableDaoBelowVersion) {
|
||||
this.bannedOfferIds = bannedOfferIds;
|
||||
this.bannedNodeAddress = bannedNodeAddress;
|
||||
this.bannedPaymentAccounts = bannedPaymentAccounts;
|
||||
@ -112,6 +117,7 @@ public final class Filter implements ProtectedStoragePayload, ExpirablePayload {
|
||||
this.preventPublicBtcNetwork = preventPublicBtcNetwork;
|
||||
this.btcNodes = btcNodes;
|
||||
this.disableDao = disableDao;
|
||||
this.disableDaoBelowVersion = disableDaoBelowVersion;
|
||||
}
|
||||
|
||||
|
||||
@ -131,6 +137,7 @@ public final class Filter implements ProtectedStoragePayload, ExpirablePayload {
|
||||
boolean preventPublicBtcNetwork,
|
||||
@Nullable List<String> btcNodes,
|
||||
boolean disableDao,
|
||||
@Nullable String disableDaoBelowVersion,
|
||||
String signatureAsBase64,
|
||||
byte[] ownerPubKeyBytes,
|
||||
@Nullable Map<String, String> extraDataMap) {
|
||||
@ -144,7 +151,8 @@ public final class Filter implements ProtectedStoragePayload, ExpirablePayload {
|
||||
priceRelayNodes,
|
||||
preventPublicBtcNetwork,
|
||||
btcNodes,
|
||||
disableDao);
|
||||
disableDao,
|
||||
disableDaoBelowVersion);
|
||||
this.signatureAsBase64 = signatureAsBase64;
|
||||
this.ownerPubKeyBytes = ownerPubKeyBytes;
|
||||
this.extraDataMap = ExtraDataMapValidator.getValidatedExtraDataMap(extraDataMap);
|
||||
@ -174,6 +182,7 @@ public final class Filter implements ProtectedStoragePayload, ExpirablePayload {
|
||||
Optional.ofNullable(seedNodes).ifPresent(builder::addAllSeedNodes);
|
||||
Optional.ofNullable(priceRelayNodes).ifPresent(builder::addAllPriceRelayNodes);
|
||||
Optional.ofNullable(btcNodes).ifPresent(builder::addAllBtcNodes);
|
||||
Optional.ofNullable(disableDaoBelowVersion).ifPresent(builder::setDisableDaoBelowVersion);
|
||||
Optional.ofNullable(extraDataMap).ifPresent(builder::putAllExtraData);
|
||||
|
||||
return PB.StoragePayload.newBuilder().setFilter(builder).build();
|
||||
@ -193,6 +202,7 @@ public final class Filter implements ProtectedStoragePayload, ExpirablePayload {
|
||||
proto.getPreventPublicBtcNetwork(),
|
||||
CollectionUtils.isEmpty(proto.getBtcNodesList()) ? null : new ArrayList<>(proto.getBtcNodesList()),
|
||||
proto.getDisableDao(),
|
||||
proto.getDisableDaoBelowVersion().isEmpty() ? null : proto.getDisableDaoBelowVersion(),
|
||||
proto.getSignatureAsBase64(),
|
||||
proto.getOwnerPubKeyBytes().toByteArray(),
|
||||
CollectionUtils.isEmpty(proto.getExtraDataMap()) ? null : proto.getExtraDataMap());
|
||||
@ -205,7 +215,7 @@ public final class Filter implements ProtectedStoragePayload, ExpirablePayload {
|
||||
|
||||
@Override
|
||||
public long getTTL() {
|
||||
return TimeUnit.DAYS.toMillis(90);
|
||||
return TimeUnit.DAYS.toMillis(180);
|
||||
}
|
||||
|
||||
public void setSigAndPubKey(String signatureAsBase64, PublicKey ownerPubKey) {
|
||||
|
@ -2075,6 +2075,7 @@ filterWindow.priceRelayNode=Filtered price relay nodes (comma sep. onion address
|
||||
filterWindow.btcNode=Filtered Bitcoin nodes (comma sep. addresses + port)
|
||||
filterWindow.preventPublicBtcNetwork=Prevent usage of public Bitcoin network
|
||||
filterWindow.disableDao=Disable DAO
|
||||
filterWindow.disableDaoBelowVersion=Min. version required for DAO
|
||||
filterWindow.add=Add filter
|
||||
filterWindow.remove=Remove filter
|
||||
|
||||
|
@ -43,7 +43,7 @@ public class UserPayloadModelVOTest {
|
||||
vo.setDisplayedAlert(new Alert("message", true, "version", new byte[]{12, -64, 12}, "string", null));
|
||||
vo.setDevelopersFilter(new Filter(Lists.newArrayList(), Lists.newArrayList(), Lists.newArrayList(),
|
||||
Lists.newArrayList(), Lists.newArrayList(), Lists.newArrayList(), Lists.newArrayList(), Lists.newArrayList(),
|
||||
false, Lists.newArrayList(), false, "string", new byte[]{10, 0, 0}, null));
|
||||
false, Lists.newArrayList(), false, null, "string", new byte[]{10, 0, 0}, null));
|
||||
vo.setRegisteredArbitrator(ArbitratorTest.getArbitratorMock());
|
||||
vo.setRegisteredMediator(MediatorTest.getMediatorMock());
|
||||
vo.setAcceptedArbitrators(Lists.newArrayList(ArbitratorTest.getArbitratorMock()));
|
||||
|
@ -141,6 +141,7 @@ public class FilterWindow extends Overlay<FilterWindow> {
|
||||
InputTextField btcNodesInputTextField = addInputTextField(gridPane, ++rowIndex, Res.get("filterWindow.btcNode"));
|
||||
CheckBox preventPublicBtcNetworkCheckBox = addLabelCheckBox(gridPane, ++rowIndex, Res.get("filterWindow.preventPublicBtcNetwork"));
|
||||
CheckBox disableDaoCheckBox = addLabelCheckBox(gridPane, ++rowIndex, Res.get("filterWindow.disableDao"));
|
||||
InputTextField disableDaoBelowVersionInputTextField = addInputTextField(gridPane, ++rowIndex, Res.get("filterWindow.disableDaoBelowVersion"));
|
||||
|
||||
final Filter filter = filterManager.getDevelopersFilter();
|
||||
if (filter != null) {
|
||||
@ -182,6 +183,7 @@ public class FilterWindow extends Overlay<FilterWindow> {
|
||||
preventPublicBtcNetworkCheckBox.setSelected(filter.isPreventPublicBtcNetwork());
|
||||
|
||||
disableDaoCheckBox.setSelected(filter.isDisableDao());
|
||||
disableDaoBelowVersionInputTextField.setText(filter.getDisableDaoBelowVersion());
|
||||
}
|
||||
Button sendButton = new AutoTooltipButton(Res.get("filterWindow.add"));
|
||||
sendButton.setOnAction(e -> {
|
||||
@ -267,7 +269,8 @@ public class FilterWindow extends Overlay<FilterWindow> {
|
||||
priceRelayNodes,
|
||||
preventPublicBtcNetworkCheckBox.isSelected(),
|
||||
btcNodes,
|
||||
disableDaoCheckBox.isSelected()),
|
||||
disableDaoCheckBox.isSelected(),
|
||||
disableDaoBelowVersionInputTextField.getText()),
|
||||
keyInputTextField.getText()))
|
||||
hide();
|
||||
else
|
||||
|
Loading…
Reference in New Issue
Block a user