-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2355 from ManfredKarrer/dao-add-filter-flag-for-d…
…isable-dao Dao add filter flag for disable dao
- Loading branch information
Showing
12 changed files
with
160 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
/* | ||
* 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.core.dao; | ||
|
||
import bisq.core.dao.exceptions.DaoDisabledException; | ||
import bisq.core.filter.Filter; | ||
import bisq.core.filter.FilterManager; | ||
|
||
import javax.inject.Inject; | ||
|
||
import lombok.Getter; | ||
|
||
public class DaoKillSwitch implements DaoSetupService { | ||
private static DaoKillSwitch INSTANCE; | ||
private final FilterManager filterManager; | ||
|
||
@Getter | ||
private boolean daoDisabled; | ||
|
||
@Inject | ||
public DaoKillSwitch(FilterManager filterManager) { | ||
this.filterManager = filterManager; | ||
|
||
DaoKillSwitch.INSTANCE = this; | ||
} | ||
|
||
@Override | ||
public void addListeners() { | ||
filterManager.filterProperty().addListener((observable, oldValue, newValue) -> applyFilter(newValue)); | ||
} | ||
|
||
@Override | ||
public void start() { | ||
applyFilter(filterManager.getFilter()); | ||
} | ||
|
||
private void applyFilter(Filter filter) { | ||
daoDisabled = filter != null && filter.isDisableDao(); | ||
} | ||
|
||
public static void assertDaoIsNotDisabled() { | ||
if (INSTANCE.isDaoDisabled()) { | ||
throw new DaoDisabledException("The DAO features have been disabled by the Bisq developers. " + | ||
"Please check out the Bisq Forum for further information."); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
core/src/main/java/bisq/core/dao/exceptions/DaoDisabledException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/* | ||
* 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.core.dao.exceptions; | ||
|
||
public class DaoDisabledException extends RuntimeException { | ||
public DaoDisabledException() { | ||
} | ||
|
||
public DaoDisabledException(String message) { | ||
super(message); | ||
} | ||
|
||
public DaoDisabledException(String message, Throwable cause) { | ||
super(message, cause); | ||
} | ||
|
||
public DaoDisabledException(Throwable cause) { | ||
super(cause); | ||
} | ||
|
||
public DaoDisabledException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { | ||
super(message, cause, enableSuppression, writableStackTrace); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters