Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Require the DAO is enabled for traders #6403

Merged
11 changes: 0 additions & 11 deletions common/src/main/java/bisq/common/app/DevEnv.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ public class DevEnv {

public static void setup(Config config) {
DevEnv.setDevMode(config.useDevMode);
DevEnv.setDaoActivated(config.daoActivated);
}

// If set to true we ignore several UI behavior like confirmation popups as well dummy accounts are created and
Expand All @@ -49,16 +48,6 @@ public static void setDevMode(boolean devMode) {
DevEnv.devMode = devMode;
}

private static boolean daoActivated = true;

public static boolean isDaoActivated() {
return daoActivated;
}

public static void setDaoActivated(boolean daoActivated) {
DevEnv.daoActivated = daoActivated;
}

public static void logErrorAndThrowIfDevMode(String msg) {
log.error(msg);
if (devMode)
Expand Down
9 changes: 0 additions & 9 deletions common/src/main/java/bisq/common/config/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,6 @@ public class Config {
public static final String GENESIS_TX_ID = "genesisTxId";
public static final String GENESIS_BLOCK_HEIGHT = "genesisBlockHeight";
public static final String GENESIS_TOTAL_SUPPLY = "genesisTotalSupply";
public static final String DAO_ACTIVATED = "daoActivated";
public static final String DUMP_DELAYED_PAYOUT_TXS = "dumpDelayedPayoutTxs";
public static final String ALLOW_FAULTY_DELAYED_TXS = "allowFaultyDelayedTxs";
public static final String API_PASSWORD = "apiPassword";
Expand Down Expand Up @@ -169,7 +168,6 @@ public class Config {
public final NetworkParameters networkParameters;
public final boolean ignoreLocalBtcNode;
public final String bitcoinRegtestHost;
public final boolean daoActivated;
public final String referralId;
public final boolean useDevMode;
public final boolean useDevModeHeader;
Expand Down Expand Up @@ -626,12 +624,6 @@ public Config(String defaultAppName, File defaultUserDataDir, String... args) {
.ofType(long.class)
.defaultsTo(-1L);

ArgumentAcceptingOptionSpec<Boolean> daoActivatedOpt =
parser.accepts(DAO_ACTIVATED, "If set to true dao is activated.")
.withRequiredArg()
.ofType(boolean.class)
.defaultsTo(true);

ArgumentAcceptingOptionSpec<Boolean> dumpDelayedPayoutTxsOpt =
parser.accepts(DUMP_DELAYED_PAYOUT_TXS, "Dump delayed payout transactions to file")
.withRequiredArg()
Expand Down Expand Up @@ -798,7 +790,6 @@ public Config(String defaultAppName, File defaultUserDataDir, String... args) {
this.genesisTxId = options.valueOf(genesisTxIdOpt);
this.genesisBlockHeight = options.valueOf(genesisBlockHeightOpt);
this.genesisTotalSupply = options.valueOf(genesisTotalSupplyOpt);
this.daoActivated = options.valueOf(daoActivatedOpt);
this.dumpDelayedPayoutTxs = options.valueOf(dumpDelayedPayoutTxsOpt);
this.allowFaultyDelayedTxs = options.valueOf(allowFaultyDelayedTxsOpt);
this.apiPassword = options.valueOf(apiPasswordOpt);
Expand Down
19 changes: 8 additions & 11 deletions core/src/main/java/bisq/core/app/DomainInitialisation.java
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@
import bisq.network.p2p.P2PService;

import bisq.common.ClockWatcher;
import bisq.common.app.DevEnv;
import bisq.common.persistence.PersistenceManager;

import javax.inject.Inject;
Expand Down Expand Up @@ -242,17 +241,15 @@ public void initDomainServices(Consumer<String> rejectedTxErrorMessageHandler,

feeService.onAllServicesInitialized(filterManager);

if (DevEnv.isDaoActivated()) {
daoSetup.onAllServicesInitialized(errorMessage -> {
if (daoErrorMessageHandler != null)
daoErrorMessageHandler.accept(errorMessage);
}, warningMessage -> {
if (daoWarnMessageHandler != null)
daoWarnMessageHandler.accept(warningMessage);
});
daoSetup.onAllServicesInitialized(errorMessage -> {
if (daoErrorMessageHandler != null)
daoErrorMessageHandler.accept(errorMessage);
}, warningMessage -> {
if (daoWarnMessageHandler != null)
daoWarnMessageHandler.accept(warningMessage);
});

daoStateSnapshotService.setDaoRequiresRestartHandler(daoRequiresRestartHandler);
}
daoStateSnapshotService.setDaoRequiresRestartHandler(daoRequiresRestartHandler);

tradeStatisticsManager.onAllServicesInitialized();

Expand Down
14 changes: 6 additions & 8 deletions core/src/main/java/bisq/core/app/misc/AppSetupWithP2PAndDAO.java
Original file line number Diff line number Diff line change
Expand Up @@ -75,14 +75,12 @@ public AppSetupWithP2PAndDAO(P2PService p2PService,
this.preferences = preferences;

// TODO Should be refactored/removed. In the meantime keep in sync with CorePersistedDataHost
if (config.daoActivated) {
persistedDataHosts.add(myVoteListService);
persistedDataHosts.add(ballotListService);
persistedDataHosts.add(myBlindVoteListService);
persistedDataHosts.add(myProposalListService);
persistedDataHosts.add(myReputationListService);
persistedDataHosts.add(myProofOfBurnListService);
}
persistedDataHosts.add(myVoteListService);
persistedDataHosts.add(ballotListService);
persistedDataHosts.add(myBlindVoteListService);
persistedDataHosts.add(myProposalListService);
persistedDataHosts.add(myReputationListService);
persistedDataHosts.add(myProofOfBurnListService);
}

@Override
Expand Down
1 change: 0 additions & 1 deletion core/src/main/java/bisq/core/dao/DaoModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,6 @@ protected void configure() {
bindConstant().annotatedWith(named(Config.RPC_BLOCK_NOTIFICATION_HOST)).to(config.rpcBlockNotificationHost);
bindConstant().annotatedWith(named(Config.DUMP_BLOCKCHAIN_DATA)).to(config.dumpBlockchainData);
bindConstant().annotatedWith(named(Config.FULL_DAO_NODE)).to(config.fullDaoNode);
bindConstant().annotatedWith(named(Config.DAO_ACTIVATED)).to(config.daoActivated);
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
import bisq.core.trade.statistics.TradeStatisticsManager;
import bisq.core.util.coin.BsqFormatter;

import bisq.common.app.DevEnv;
import bisq.common.handlers.ErrorMessageHandler;
import bisq.common.handlers.ResultHandler;

Expand Down Expand Up @@ -189,7 +188,7 @@ public void updateAssetStates() {
}

public boolean isActive(String tickerSymbol) {
return DevEnv.isDaoActivated() ? findAsset(tickerSymbol).map(StatefulAsset::isActive).orElse(false) : true;
return findAsset(tickerSymbol).map(StatefulAsset::isActive).orElse(false);
}

public Transaction payFee(StatefulAsset statefulAsset,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
import bisq.core.dao.state.model.governance.Proposal;
import bisq.core.dao.state.model.governance.Vote;

import bisq.common.app.DevEnv;
import bisq.common.persistence.PersistenceManager;
import bisq.common.proto.persistable.PersistedDataHost;

Expand Down Expand Up @@ -130,16 +129,12 @@ public void start() {

@Override
public void readPersisted(Runnable completeHandler) {
if (DevEnv.isDaoActivated()) {
persistenceManager.readPersisted(persisted -> {
ballotList.setAll(persisted.getList());
listeners.forEach(l -> l.onListChanged(ballotList.getList()));
completeHandler.run();
},
completeHandler);
} else {
completeHandler.run();
}
persistenceManager.readPersisted(persisted -> {
ballotList.setAll(persisted.getList());
listeners.forEach(l -> l.onListChanged(ballotList.getList()));
completeHandler.run();
},
completeHandler);
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@
import bisq.network.p2p.storage.persistence.AppendOnlyDataStoreListener;
import bisq.network.p2p.storage.persistence.AppendOnlyDataStoreService;

import bisq.common.config.Config;

import javax.inject.Inject;

import javafx.collections.FXCollections;
Expand Down Expand Up @@ -67,16 +65,14 @@ public BlindVoteListService(DaoStateService daoStateService,
PeriodService periodService,
BlindVoteStorageService blindVoteStorageService,
AppendOnlyDataStoreService appendOnlyDataStoreService,
BlindVoteValidator blindVoteValidator,
Config config) {
BlindVoteValidator blindVoteValidator) {
this.daoStateService = daoStateService;
this.p2PService = p2PService;
this.periodService = periodService;
this.blindVoteStorageService = blindVoteStorageService;
this.blindVoteValidator = blindVoteValidator;

if (config.daoActivated)
appendOnlyDataStoreService.addService(blindVoteStorageService);
appendOnlyDataStoreService.addService(blindVoteStorageService);
}


Expand Down Expand Up @@ -151,7 +147,8 @@ private void fillListFromAppendOnlyDataStore() {
blindVoteStorageService.getMap().values().forEach(e -> onAppendOnlyDataAdded(e, false));
}

private void onAppendOnlyDataAdded(PersistableNetworkPayload persistableNetworkPayload, boolean fromBroadcastMessage) {
private void onAppendOnlyDataAdded(PersistableNetworkPayload persistableNetworkPayload,
boolean fromBroadcastMessage) {
if (persistableNetworkPayload instanceof BlindVotePayload) {
BlindVotePayload blindVotePayload = (BlindVotePayload) persistableNetworkPayload;
if (!blindVotePayloads.contains(blindVotePayload)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@
import bisq.network.p2p.P2PService;

import bisq.common.UserThread;
import bisq.common.app.DevEnv;
import bisq.common.config.Config;
import bisq.common.crypto.CryptoException;
import bisq.common.handlers.ErrorMessageHandler;
Expand Down Expand Up @@ -163,15 +162,11 @@ public void start() {

@Override
public void readPersisted(Runnable completeHandler) {
if (DevEnv.isDaoActivated()) {
persistenceManager.readPersisted(persisted -> {
myBlindVoteList.setAll(persisted.getList());
completeHandler.run();
},
completeHandler);
} else {
completeHandler.run();
}
persistenceManager.readPersisted(persisted -> {
myBlindVoteList.setAll(persisted.getList());
completeHandler.run();
},
completeHandler);
}


Expand Down Expand Up @@ -233,7 +228,7 @@ public void publishBlindVote(Coin stake, ResultHandler resultHandler, ExceptionH

publishTx(resultHandler, exceptionHandler, blindVoteTx);
} catch (CryptoException | TransactionVerificationException | InsufficientMoneyException |
WalletException | IOException exception) {
WalletException | IOException exception) {
log.error(exception.toString());
exception.printStackTrace();
exceptionHandler.handleException(exception);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

import bisq.core.dao.DaoSetupService;

import bisq.common.app.DevEnv;
import bisq.common.persistence.PersistenceManager;
import bisq.common.proto.persistable.PersistedDataHost;

Expand Down Expand Up @@ -56,15 +55,11 @@ public MyReputationListService(PersistenceManager<MyReputationList> persistenceM

@Override
public void readPersisted(Runnable completeHandler) {
if (DevEnv.isDaoActivated()) {
persistenceManager.readPersisted(persisted -> {
myReputationList.setAll(persisted.getList());
completeHandler.run();
},
completeHandler);
} else {
completeHandler.run();
}
persistenceManager.readPersisted(persisted -> {
myReputationList.setAll(persisted.getList());
completeHandler.run();
},
completeHandler);
}

///////////////////////////////////////////////////////////////////////////////////////////
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import bisq.core.dao.state.model.governance.Ballot;
import bisq.core.dao.state.model.governance.BallotList;

import bisq.common.app.DevEnv;
import bisq.common.crypto.Encryption;
import bisq.common.persistence.PersistenceManager;
import bisq.common.proto.persistable.PersistedDataHost;
Expand Down Expand Up @@ -70,15 +69,11 @@ public MyVoteListService(DaoStateService daoStateService,

@Override
public void readPersisted(Runnable completeHandler) {
if (DevEnv.isDaoActivated()) {
persistenceManager.readPersisted(persisted -> {
myVoteList.setAll(persisted.getList());
completeHandler.run();
},
completeHandler);
} else {
completeHandler.run();
}
persistenceManager.readPersisted(persisted -> {
myVoteList.setAll(persisted.getList());
completeHandler.run();
},
completeHandler);
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

import bisq.core.dao.DaoSetupService;

import bisq.common.app.DevEnv;
import bisq.common.persistence.PersistenceManager;
import bisq.common.proto.persistable.PersistedDataHost;

Expand Down Expand Up @@ -56,15 +55,11 @@ public MyProofOfBurnListService(PersistenceManager<MyProofOfBurnList> persistenc

@Override
public void readPersisted(Runnable completeHandler) {
if (DevEnv.isDaoActivated()) {
persistenceManager.readPersisted(persisted -> {
myProofOfBurnList.setAll(persisted.getList());
completeHandler.run();
},
completeHandler);
} else {
completeHandler.run();
}
persistenceManager.readPersisted(persisted -> {
myProofOfBurnList.setAll(persisted.getList());
completeHandler.run();
},
completeHandler);
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,16 +108,12 @@ public MyProposalListService(P2PService p2PService,

@Override
public void readPersisted(Runnable completeHandler) {
if (DevEnv.isDaoActivated()) {
persistenceManager.readPersisted(persisted -> {
myProposalList.setAll(persisted.getList());
listeners.forEach(l -> l.onListChanged(getList()));
completeHandler.run();
},
completeHandler);
} else {
completeHandler.run();
}
persistenceManager.readPersisted(persisted -> {
myProposalList.setAll(persisted.getList());
listeners.forEach(l -> l.onListChanged(getList()));
completeHandler.run();
},
completeHandler);
}


Expand Down
Loading