Move 'btcNetworkDir' and co from BisqEnvironment to Config

This commit is contained in:
Chris Beams 2019-12-11 20:34:48 +01:00
parent 70bdccb258
commit f3e0b853db
No known key found for this signature in database
GPG key ID: 3D214F8F5BC5ED73
32 changed files with 93 additions and 76 deletions

View file

@ -28,6 +28,10 @@ public class Config {
public static final String REFERRAL_ID = "referralId";
public static final String USE_DEV_MODE = "useDevMode";
public static final String TOR_DIR = "torDir";
public static final String STORAGE_DIR = "storageDir";
public static final String KEY_STORAGE_DIR = "keyStorageDir";
public static final String WALLET_DIR = "walletDir";
static final String DEFAULT_CONFIG_FILE_NAME = "bisq.properties";
static final int DEFAULT_NODE_PORT = 9999;
@ -59,8 +63,12 @@ public class Config {
private final String referralId;
private final boolean useDevMode;
// FIXME: Carryover from legacy BisqEnvironment; there should be no mutable state here
private boolean localBitcoinNodeIsRunning = false;
// properties derived from cli options, but not exposed as cli options themselves
private boolean localBitcoinNodeIsRunning = false; // FIXME: eliminate mutable state
private final File torDir;
private final File walletDir;
private final File storageDir;
private final File keyStorageDir;
public Config(String defaultAppName) throws HelpRequested {
this(defaultAppName, new String[]{});
@ -251,6 +259,15 @@ public class Config {
ex.getCause().getMessage() :
ex.getMessage()));
}
File btcNetworkDir = new File(appDataDir, baseCurrencyNetwork.name().toLowerCase());
if (!btcNetworkDir.exists())
btcNetworkDir.mkdir();
this.torDir = new File(btcNetworkDir, "tor");
this.walletDir = btcNetworkDir;
this.storageDir = new File(btcNetworkDir, "db");
this.keyStorageDir = new File(btcNetworkDir, "keys");
}
private Optional<OptionSet> parseOptionsFrom(File file, OptionParser parser, OptionSpec<?>... disallowedOpts) {
@ -370,4 +387,20 @@ public class Config {
public boolean isUseDevMode() {
return useDevMode;
}
public File getTorDir() {
return torDir;
}
public File getWalletDir() {
return walletDir;
}
public File getStorageDir() {
return storageDir;
}
public File getKeyStorageDir() {
return keyStorageDir;
}
}

View file

@ -17,6 +17,7 @@
package bisq.common.crypto;
import bisq.common.config.Config;
import bisq.common.storage.FileUtil;
import com.google.inject.Inject;
@ -57,8 +58,6 @@ import org.jetbrains.annotations.NotNull;
public class KeyStorage {
private static final Logger log = LoggerFactory.getLogger(KeyStorage.class);
public static final String KEY_STORAGE_DIR = "keyStorageDir";
public enum KeyEntry {
MSG_SIGNATURE("sig", Sig.KEY_ALGO),
MSG_ENCRYPTION("enc", Encryption.ASYM_KEY_ALGO);
@ -92,7 +91,7 @@ public class KeyStorage {
private final File storageDir;
@Inject
public KeyStorage(@Named(KEY_STORAGE_DIR) File storageDir) {
public KeyStorage(@Named(Config.KEY_STORAGE_DIR) File storageDir) {
storageDir.mkdirs();
this.storageDir = storageDir;
}

View file

@ -18,6 +18,7 @@
package bisq.common.storage;
import bisq.common.app.DevEnv;
import bisq.common.config.Config;
import bisq.common.proto.persistable.PersistableEnvelope;
import bisq.common.proto.persistable.PersistenceProtoResolver;
@ -50,7 +51,6 @@ import static com.google.common.base.Preconditions.checkNotNull;
*/
public class Storage<T extends PersistableEnvelope> {
private static final Logger log = LoggerFactory.getLogger(Storage.class);
public static final String STORAGE_DIR = "storageDir";
private final CorruptedDatabaseFilesHandler corruptedDatabaseFilesHandler;
@ -68,7 +68,7 @@ public class Storage<T extends PersistableEnvelope> {
///////////////////////////////////////////////////////////////////////////////////////////
@Inject
public Storage(@Named(STORAGE_DIR) File dir,
public Storage(@Named(Config.STORAGE_DIR) File dir,
PersistenceProtoResolver persistenceProtoResolver,
CorruptedDatabaseFilesHandler corruptedDatabaseFilesHandler) {
this.dir = dir;

View file

@ -21,6 +21,7 @@ import bisq.network.p2p.storage.P2PDataStorage;
import bisq.network.p2p.storage.payload.PersistableNetworkPayload;
import bisq.network.p2p.storage.persistence.MapStoreService;
import bisq.common.config.Config;
import bisq.common.storage.Storage;
import javax.inject.Named;
@ -44,7 +45,7 @@ public class SignedWitnessStorageService extends MapStoreService<SignedWitnessSt
///////////////////////////////////////////////////////////////////////////////////////////
@Inject
public SignedWitnessStorageService(@Named(Storage.STORAGE_DIR) File storageDir,
public SignedWitnessStorageService(@Named(Config.STORAGE_DIR) File storageDir,
Storage<SignedWitnessStore> persistableNetworkPayloadMapStorage) {
super(storageDir, persistableNetworkPayloadMapStorage);
}

View file

@ -21,6 +21,7 @@ import bisq.network.p2p.storage.P2PDataStorage;
import bisq.network.p2p.storage.payload.PersistableNetworkPayload;
import bisq.network.p2p.storage.persistence.MapStoreService;
import bisq.common.config.Config;
import bisq.common.storage.Storage;
import javax.inject.Named;
@ -44,7 +45,7 @@ public class AccountAgeWitnessStorageService extends MapStoreService<AccountAgeW
///////////////////////////////////////////////////////////////////////////////////////////
@Inject
public AccountAgeWitnessStorageService(@Named(Storage.STORAGE_DIR) File storageDir,
public AccountAgeWitnessStorageService(@Named(Config.STORAGE_DIR) File storageDir,
Storage<AccountAgeWitnessStore> persistableNetworkPayloadMapStorage) {
super(storageDir, persistableNetworkPayloadMapStorage);
}

View file

@ -28,9 +28,6 @@ import bisq.common.BisqException;
import bisq.common.CommonOptionKeys;
import bisq.common.app.Version;
import bisq.common.config.BaseCurrencyNetwork;
import bisq.common.config.Config;
import bisq.common.crypto.KeyStorage;
import bisq.common.storage.Storage;
import bisq.common.util.Utilities;
import org.springframework.core.env.JOptCommandLinePropertySource;
@ -136,7 +133,7 @@ public class BisqEnvironment extends StandardEnvironment {
protected final String userDataDir;
@Getter
protected final String appDataDir;
protected final String btcNetworkDir, userAgent;
protected final String userAgent;
protected final String logLevel, providers;
@Getter
@Setter
@ -226,13 +223,6 @@ public class BisqEnvironment extends StandardEnvironment {
BaseCurrencyNetwork.BTC_MAINNET.name()).toUpperCase());
BaseCurrencyNetwork.CURRENT_PARAMETERS = BaseCurrencyNetwork.CURRENT_NETWORK.getParameters();
btcNetworkDir = Paths.get(appDataDir, BaseCurrencyNetwork.CURRENT_NETWORK.name().toLowerCase()).toString();
File btcNetworkDirFile = new File(btcNetworkDir);
if (!btcNetworkDirFile.exists())
//noinspection ResultOfMethodCallIgnored
btcNetworkDirFile.mkdir();
// btcNetworkDir used in defaultProperties
propertySources.addLast(defaultProperties());
} catch (Exception ex) {
throw new BisqException(ex);
@ -264,7 +254,6 @@ public class BisqEnvironment extends StandardEnvironment {
setProperty(NetworkOptionKeys.SEED_NODES_KEY, seedNodes);
setProperty(NetworkOptionKeys.BAN_LIST, banList);
setProperty(NetworkOptionKeys.TOR_DIR, Paths.get(btcNetworkDir, "tor").toString());
setProperty(NetworkOptionKeys.NETWORK_ID, String.valueOf(BaseCurrencyNetwork.CURRENT_NETWORK.ordinal()));
setProperty(NetworkOptionKeys.SOCKS_5_PROXY_BTC_ADDRESS, socks5ProxyBtcAddress);
setProperty(NetworkOptionKeys.SOCKS_5_PROXY_HTTP_ADDRESS, socks5ProxyHttpAddress);
@ -307,7 +296,6 @@ public class BisqEnvironment extends StandardEnvironment {
setProperty(BtcOptionKeys.BTC_NODES, btcNodes);
setProperty(BtcOptionKeys.USE_TOR_FOR_BTC, useTorForBtc);
setProperty(BtcOptionKeys.WALLET_DIR, btcNetworkDir);
setProperty(BtcOptionKeys.USER_AGENT, userAgent);
setProperty(BtcOptionKeys.USE_ALL_PROVIDED_NODES, useAllProvidedNodes);
setProperty(BtcOptionKeys.NUM_CONNECTIONS_FOR_BTC, numConnectionForBtc);
@ -315,9 +303,6 @@ public class BisqEnvironment extends StandardEnvironment {
setProperty(UserAgent.NAME_KEY, appName);
setProperty(UserAgent.VERSION_KEY, Version.VERSION);
setProperty(Storage.STORAGE_DIR, Paths.get(btcNetworkDir, "db").toString());
setProperty(KeyStorage.KEY_STORAGE_DIR, Paths.get(btcNetworkDir, "keys").toString());
}
});
}

View file

@ -59,8 +59,6 @@ import joptsimple.util.RegexMatcher;
import com.google.inject.Guice;
import com.google.inject.Injector;
import com.google.inject.Key;
import com.google.inject.name.Names;
import java.nio.file.Files;
import java.nio.file.Path;

View file

@ -41,12 +41,10 @@ import bisq.network.p2p.network.BridgeAddressProvider;
import bisq.network.p2p.seed.SeedNodeRepository;
import bisq.common.app.AppModule;
import bisq.common.crypto.KeyStorage;
import bisq.common.crypto.PubKeyRing;
import bisq.common.crypto.PubKeyRingProvider;
import bisq.common.proto.network.NetworkProtoResolver;
import bisq.common.proto.persistable.PersistenceProtoResolver;
import bisq.common.storage.Storage;
import org.springframework.core.env.Environment;
@ -54,7 +52,9 @@ import com.google.inject.name.Names;
import java.io.File;
import static bisq.common.config.Config.KEY_STORAGE_DIR;
import static bisq.common.config.Config.REFERRAL_ID;
import static bisq.common.config.Config.STORAGE_DIR;
import static bisq.common.config.Config.USE_DEV_MODE;
import static com.google.inject.name.Names.named;
@ -73,14 +73,12 @@ public class CoreModule extends AppModule {
bind(SeedNodeRepository.class).to(DefaultSeedNodeRepository.class);
File storageDir = new File(environment.getRequiredProperty(Storage.STORAGE_DIR));
bind(File.class).annotatedWith(named(Storage.STORAGE_DIR)).toInstance(storageDir);
bind(File.class).annotatedWith(named(STORAGE_DIR)).toInstance(config.getStorageDir());
CoinFormatter btcFormatter = new ImmutableCoinFormatter(BaseCurrencyNetwork.CURRENT_PARAMETERS.getMonetaryFormat());
bind(CoinFormatter.class).annotatedWith(named(FormattingUtils.BTC_FORMATTER_KEY)).toInstance(btcFormatter);
File keyStorageDir = new File(environment.getRequiredProperty(KeyStorage.KEY_STORAGE_DIR));
bind(File.class).annotatedWith(named(KeyStorage.KEY_STORAGE_DIR)).toInstance(keyStorageDir);
bind(File.class).annotatedWith(named(KEY_STORAGE_DIR)).toInstance(config.getKeyStorageDir());
bind(NetworkProtoResolver.class).to(CoreNetworkProtoResolver.class);
bind(PersistenceProtoResolver.class).to(CorePersistenceProtoResolver.class);

View file

@ -17,8 +17,7 @@
package bisq.core.app;
import bisq.network.NetworkOptionKeys;
import bisq.common.config.Config;
import bisq.common.handlers.ErrorMessageHandler;
import bisq.common.storage.FileUtil;
@ -42,7 +41,7 @@ public class TorSetup {
private File torDir;
@Inject
public TorSetup(@Named(NetworkOptionKeys.TOR_DIR) File torDir) {
public TorSetup(@Named(Config.TOR_DIR) File torDir) {
this.torDir = torDir;
}

View file

@ -46,7 +46,6 @@ import bisq.common.crypto.PubKeyRing;
import bisq.common.crypto.PubKeyRingProvider;
import bisq.common.proto.network.NetworkProtoResolver;
import bisq.common.proto.persistable.PersistenceProtoResolver;
import bisq.common.storage.Storage;
import org.springframework.core.env.Environment;
@ -55,7 +54,9 @@ import com.google.inject.name.Names;
import java.io.File;
import static bisq.common.config.Config.KEY_STORAGE_DIR;
import static bisq.common.config.Config.REFERRAL_ID;
import static bisq.common.config.Config.STORAGE_DIR;
import static bisq.common.config.Config.USE_DEV_MODE;
import static com.google.inject.name.Names.named;
@ -82,11 +83,8 @@ public class ModuleForAppWithP2p extends AppModule {
bind(SeedNodeRepository.class).to(DefaultSeedNodeRepository.class).in(Singleton.class);
File storageDir = new File(environment.getRequiredProperty(Storage.STORAGE_DIR));
bind(File.class).annotatedWith(named(Storage.STORAGE_DIR)).toInstance(storageDir);
File keyStorageDir = new File(environment.getRequiredProperty(KeyStorage.KEY_STORAGE_DIR));
bind(File.class).annotatedWith(named(KeyStorage.KEY_STORAGE_DIR)).toInstance(keyStorageDir);
bind(File.class).annotatedWith(named(STORAGE_DIR)).toInstance(config.getStorageDir());
bind(File.class).annotatedWith(named(KEY_STORAGE_DIR)).toInstance(config.getKeyStorageDir());
Boolean useDevPrivilegeKeys = environment.getProperty(AppOptionKeys.USE_DEV_PRIVILEGE_KEYS, Boolean.class, false);
bind(boolean.class).annotatedWith(Names.named(AppOptionKeys.USE_DEV_PRIVILEGE_KEYS)).toInstance(useDevPrivilegeKeys);

View file

@ -45,6 +45,7 @@ import java.io.File;
import java.util.Arrays;
import static bisq.common.config.Config.WALLET_DIR;
import static com.google.inject.name.Names.named;
public class BitcoinModule extends AppModule {
@ -79,8 +80,7 @@ public class BitcoinModule extends AppModule {
bindConstant().annotatedWith(named(UserAgent.VERSION_KEY)).to(environment.getRequiredProperty(UserAgent.VERSION_KEY));
bind(UserAgent.class).in(Singleton.class);
File walletDir = new File(environment.getRequiredProperty(BtcOptionKeys.WALLET_DIR));
bind(File.class).annotatedWith(named(BtcOptionKeys.WALLET_DIR)).toInstance(walletDir);
bind(File.class).annotatedWith(named(WALLET_DIR)).toInstance(config.getWalletDir());
bindConstant().annotatedWith(named(BtcOptionKeys.BTC_NODES)).to(environment.getRequiredProperty(BtcOptionKeys.BTC_NODES));
bindConstant().annotatedWith(named(BtcOptionKeys.USER_AGENT)).to(environment.getRequiredProperty(BtcOptionKeys.USER_AGENT));

View file

@ -22,7 +22,6 @@ public class BtcOptionKeys {
public static final String USE_TOR_FOR_BTC = "useTorForBtc";
public static final String SOCKS5_DISCOVER_MODE = "socks5DiscoverMode";
public static final String BASE_CURRENCY_NETWORK = "baseCurrencyNetwork";
public static final String WALLET_DIR = "walletDir";
public static final String USER_AGENT = "userAgent";
public static final String USE_ALL_PROVIDED_NODES = "useAllProvidedNodes"; // We only use onion nodes if tor is enabled. That flag overrides that default behavior.
public static final String NUM_CONNECTIONS_FOR_BTC = "numConnectionForBtc";

View file

@ -151,7 +151,7 @@ public class WalletsSetup {
Config config,
BtcNodes btcNodes,
@Named(BtcOptionKeys.USER_AGENT) String userAgent,
@Named(BtcOptionKeys.WALLET_DIR) File appDir,
@Named(Config.WALLET_DIR) File appDir,
@Named(BtcOptionKeys.USE_ALL_PROVIDED_NODES) String useAllProvidedNodes,
@Named(BtcOptionKeys.NUM_CONNECTIONS_FOR_BTC) String numConnectionForBtc,
@Named(BtcOptionKeys.SOCKS5_DISCOVER_MODE) String socks5DiscoverModeString) {

View file

@ -21,6 +21,7 @@ import bisq.network.p2p.storage.P2PDataStorage;
import bisq.network.p2p.storage.payload.PersistableNetworkPayload;
import bisq.network.p2p.storage.persistence.MapStoreService;
import bisq.common.config.Config;
import bisq.common.storage.Storage;
import javax.inject.Named;
@ -48,7 +49,7 @@ public class BlindVoteStorageService extends MapStoreService<BlindVoteStore, Per
///////////////////////////////////////////////////////////////////////////////////////////
@Inject
public BlindVoteStorageService(@Named(Storage.STORAGE_DIR) File storageDir,
public BlindVoteStorageService(@Named(Config.STORAGE_DIR) File storageDir,
Storage<BlindVoteStore> persistableNetworkPayloadMapStorage) {
super(storageDir, persistableNetworkPayloadMapStorage);
}

View file

@ -21,6 +21,7 @@ import bisq.network.p2p.storage.P2PDataStorage;
import bisq.network.p2p.storage.payload.PersistableNetworkPayload;
import bisq.network.p2p.storage.persistence.MapStoreService;
import bisq.common.config.Config;
import bisq.common.storage.Storage;
import javax.inject.Named;
@ -42,7 +43,7 @@ public class ProposalStorageService extends MapStoreService<ProposalStore, Persi
///////////////////////////////////////////////////////////////////////////////////////////
@Inject
public ProposalStorageService(@Named(Storage.STORAGE_DIR) File storageDir,
public ProposalStorageService(@Named(Config.STORAGE_DIR) File storageDir,
Storage<ProposalStore> persistableNetworkPayloadMapStorage) {
super(storageDir, persistableNetworkPayloadMapStorage);
}

View file

@ -21,6 +21,7 @@ import bisq.network.p2p.storage.P2PDataStorage;
import bisq.network.p2p.storage.payload.ProtectedStorageEntry;
import bisq.network.p2p.storage.persistence.MapStoreService;
import bisq.common.config.Config;
import bisq.common.storage.Storage;
import javax.inject.Named;
@ -42,7 +43,7 @@ public class TempProposalStorageService extends MapStoreService<TempProposalStor
///////////////////////////////////////////////////////////////////////////////////////////
@Inject
public TempProposalStorageService(@Named(Storage.STORAGE_DIR) File storageDir,
public TempProposalStorageService(@Named(Config.STORAGE_DIR) File storageDir,
Storage<TempProposalStore> persistableNetworkPayloadMapStorage) {
super(storageDir, persistableNetworkPayloadMapStorage);
}

View file

@ -38,9 +38,9 @@ import bisq.network.p2p.network.Connection;
import bisq.network.p2p.seed.SeedNodeRepository;
import bisq.common.UserThread;
import bisq.common.config.Config;
import bisq.common.crypto.Hash;
import bisq.common.storage.FileManager;
import bisq.common.storage.Storage;
import bisq.common.util.Utilities;
import javax.inject.Inject;
@ -131,7 +131,7 @@ public class DaoStateMonitoringService implements DaoSetupService, DaoStateListe
DaoStateNetworkService daoStateNetworkService,
GenesisTxInfo genesisTxInfo,
SeedNodeRepository seedNodeRepository,
@Named(Storage.STORAGE_DIR) File storageDir,
@Named(Config.STORAGE_DIR) File storageDir,
@Named(AppOptionKeys.IGNORE_DEV_MSG_KEY) boolean ignoreDevMsg) {
this.daoStateService = daoStateService;
this.daoStateNetworkService = daoStateNetworkService;

View file

@ -27,9 +27,9 @@ import bisq.core.dao.state.model.blockchain.Tx;
import bisq.core.dao.state.model.blockchain.TxOutput;
import bisq.core.dao.state.model.blockchain.TxType;
import bisq.common.config.Config;
import bisq.common.storage.FileUtil;
import bisq.common.storage.JsonFileManager;
import bisq.common.storage.Storage;
import bisq.common.util.Utilities;
import org.bitcoinj.core.Utils;
@ -70,7 +70,7 @@ public class ExportJsonFilesService implements DaoSetupService {
@Inject
public ExportJsonFilesService(DaoStateService daoStateService,
@Named(Storage.STORAGE_DIR) File storageDir,
@Named(Config.STORAGE_DIR) File storageDir,
@Named(DaoOptionKeys.DUMP_BLOCKCHAIN_DATA) boolean dumpBlockchainData) {
this.daoStateService = daoStateService;
this.storageDir = storageDir;

View file

@ -25,6 +25,7 @@ import bisq.network.p2p.storage.persistence.ResourceDataStoreService;
import bisq.network.p2p.storage.persistence.StoreService;
import bisq.common.UserThread;
import bisq.common.config.Config;
import bisq.common.storage.Storage;
import javax.inject.Inject;
@ -61,7 +62,7 @@ public class DaoStateStorageService extends StoreService<DaoStateStore> {
public DaoStateStorageService(ResourceDataStoreService resourceDataStoreService,
DaoState daoState,
DaoStateMonitoringService daoStateMonitoringService,
@Named(Storage.STORAGE_DIR) File storageDir,
@Named(Config.STORAGE_DIR) File storageDir,
Storage<DaoStateStore> daoSnapshotStorage) {
super(storageDir, daoSnapshotStorage);
this.daoState = daoState;

View file

@ -28,10 +28,10 @@ import bisq.network.p2p.storage.HashMapChangedListener;
import bisq.network.p2p.storage.payload.ProtectedStorageEntry;
import bisq.common.UserThread;
import bisq.common.config.Config;
import bisq.common.handlers.ErrorMessageHandler;
import bisq.common.handlers.ResultHandler;
import bisq.common.storage.JsonFileManager;
import bisq.common.storage.Storage;
import bisq.common.util.Utilities;
import javax.inject.Named;
@ -79,7 +79,7 @@ public class OfferBookService {
public OfferBookService(P2PService p2PService,
PriceFeedService priceFeedService,
FilterManager filterManager,
@Named(Storage.STORAGE_DIR) File storageDir,
@Named(Config.STORAGE_DIR) File storageDir,
@Named(AppOptionKeys.DUMP_STATISTICS) boolean dumpStatistics) {
this.p2PService = p2PService;
this.priceFeedService = priceFeedService;

View file

@ -47,6 +47,7 @@ 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;
import bisq.common.proto.ProtobufferRuntimeException;
import bisq.common.proto.network.NetworkProtoResolver;
import bisq.common.proto.persistable.NavigationPath;
@ -77,7 +78,7 @@ public class CorePersistenceProtoResolver extends CoreProtoResolver implements P
@Inject
public CorePersistenceProtoResolver(Provider<BtcWalletService> btcWalletService,
NetworkProtoResolver networkProtoResolver,
@Named(Storage.STORAGE_DIR) File storageDir,
@Named(Config.STORAGE_DIR) File storageDir,
CorruptedDatabaseFilesHandler corruptedDatabaseFilesHandler) {
this.btcWalletService = btcWalletService;
this.networkProtoResolver = networkProtoResolver;

View file

@ -21,6 +21,7 @@ import bisq.network.p2p.storage.P2PDataStorage;
import bisq.network.p2p.storage.payload.PersistableNetworkPayload;
import bisq.network.p2p.storage.persistence.MapStoreService;
import bisq.common.config.Config;
import bisq.common.storage.Storage;
import javax.inject.Named;
@ -43,7 +44,7 @@ public class TradeStatistics2StorageService extends MapStoreService<TradeStatist
///////////////////////////////////////////////////////////////////////////////////////////
@Inject
public TradeStatistics2StorageService(@Named(Storage.STORAGE_DIR) File storageDir,
public TradeStatistics2StorageService(@Named(Config.STORAGE_DIR) File storageDir,
Storage<TradeStatistics2Store> persistableNetworkPayloadMapStorage) {
super(storageDir, persistableNetworkPayloadMapStorage);
}

View file

@ -26,8 +26,8 @@ import bisq.core.provider.price.PriceFeedService;
import bisq.network.p2p.P2PService;
import bisq.network.p2p.storage.persistence.AppendOnlyDataStoreService;
import bisq.common.config.Config;
import bisq.common.storage.JsonFileManager;
import bisq.common.storage.Storage;
import bisq.common.util.Utilities;
import com.google.inject.Inject;
@ -60,7 +60,7 @@ public class TradeStatisticsManager {
PriceFeedService priceFeedService,
TradeStatistics2StorageService tradeStatistics2StorageService,
AppendOnlyDataStoreService appendOnlyDataStoreService,
@Named(Storage.STORAGE_DIR) File storageDir,
@Named(Config.STORAGE_DIR) File storageDir,
@Named(AppOptionKeys.DUMP_STATISTICS) boolean dumpStatistics) {
this.p2PService = p2PService;
this.priceFeedService = priceFeedService;

View file

@ -29,7 +29,7 @@ import bisq.core.btc.wallet.WalletsManager;
import bisq.core.locale.Res;
import bisq.core.user.DontShowAgainLookup;
import bisq.common.storage.Storage;
import bisq.common.config.Config;
import org.bitcoinj.crypto.MnemonicCode;
import org.bitcoinj.crypto.MnemonicException;
@ -53,7 +53,6 @@ import javafx.beans.value.ChangeListener;
import java.time.Instant;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.Month;
import java.time.ZoneId;
import java.time.ZoneOffset;
@ -94,7 +93,7 @@ public class SeedWordsView extends ActivatableView<GridPane, Void> {
private SeedWordsView(WalletsManager walletsManager,
BtcWalletService btcWalletService,
WalletPasswordWindow walletPasswordWindow,
@Named(Storage.STORAGE_DIR) File storageDir) {
@Named(Config.STORAGE_DIR) File storageDir) {
this.walletsManager = walletsManager;
this.btcWalletService = btcWalletService;
this.walletPasswordWindow = walletPasswordWindow;

View file

@ -33,7 +33,7 @@ import bisq.core.locale.Res;
import bisq.network.p2p.seed.SeedNodeRepository;
import bisq.common.storage.Storage;
import bisq.common.config.Config;
import javax.inject.Inject;
import javax.inject.Named;
@ -69,7 +69,7 @@ public class BlindVoteStateMonitorView extends StateMonitorView<BlindVoteStateHa
CycleService cycleService,
PeriodService periodService,
SeedNodeRepository seedNodeRepository,
@Named(Storage.STORAGE_DIR) File storageDir) {
@Named(Config.STORAGE_DIR) File storageDir) {
super(daoStateService, daoFacade, cycleService, periodService, seedNodeRepository, storageDir);
this.blindVoteStateMonitoringService = blindVoteStateMonitoringService;

View file

@ -35,7 +35,7 @@ import bisq.core.locale.Res;
import bisq.network.p2p.seed.SeedNodeRepository;
import bisq.common.storage.Storage;
import bisq.common.config.Config;
import bisq.common.util.Utilities;
import javax.inject.Inject;
@ -68,7 +68,7 @@ public class DaoStateMonitorView extends StateMonitorView<DaoStateHash, DaoState
CycleService cycleService,
PeriodService periodService,
SeedNodeRepository seedNodeRepository,
@Named(Storage.STORAGE_DIR) File storageDir) {
@Named(Config.STORAGE_DIR) File storageDir) {
super(daoStateService, daoFacade, cycleService, periodService, seedNodeRepository, storageDir);
this.daoStateMonitoringService = daoStateMonitoringService;

View file

@ -33,7 +33,7 @@ import bisq.core.locale.Res;
import bisq.network.p2p.seed.SeedNodeRepository;
import bisq.common.storage.Storage;
import bisq.common.config.Config;
import javax.inject.Inject;
import javax.inject.Named;
@ -68,7 +68,7 @@ public class ProposalStateMonitorView extends StateMonitorView<ProposalStateHash
CycleService cycleService,
PeriodService periodService,
SeedNodeRepository seedNodeRepository,
@Named(Storage.STORAGE_DIR) File storageDir) {
@Named(Config.STORAGE_DIR) File storageDir) {
super(daoStateService, daoFacade, cycleService, periodService, seedNodeRepository, storageDir);
this.proposalStateMonitoringService = proposalStateMonitoringService;

View file

@ -32,7 +32,7 @@ import bisq.core.crypto.ScryptUtil;
import bisq.core.locale.Res;
import bisq.common.UserThread;
import bisq.common.storage.Storage;
import bisq.common.config.Config;
import bisq.common.util.Tuple2;
import org.bitcoinj.crypto.KeyCrypterScrypt;
@ -115,7 +115,7 @@ public class WalletPasswordWindow extends Overlay<WalletPasswordWindow> {
@Inject
private WalletPasswordWindow(WalletsManager walletsManager,
@Named(Storage.STORAGE_DIR) File storageDir) {
@Named(Config.STORAGE_DIR) File storageDir) {
this.walletsManager = walletsManager;
this.storageDir = storageDir;
type = Type.Attention;

View file

@ -18,7 +18,6 @@
package bisq.network;
public class NetworkOptionKeys {
public static final String TOR_DIR = "torDir";
public static final String USE_LOCALHOST_FOR_P2P = "useLocalhostForP2P";
public static final String MAX_CONNECTIONS = "maxConnections";
public static final String PORT_KEY = "nodePort";

View file

@ -25,6 +25,7 @@ import bisq.network.p2p.network.NewTor;
import bisq.network.p2p.network.RunningTor;
import bisq.network.p2p.network.TorNetworkNode;
import bisq.common.config.Config;
import bisq.common.proto.network.NetworkProtoResolver;
import javax.inject.Provider;
@ -43,7 +44,7 @@ public class NetworkNodeProvider implements Provider<NetworkNode> {
BridgeAddressProvider bridgeAddressProvider,
@Named(NetworkOptionKeys.USE_LOCALHOST_FOR_P2P) boolean useLocalhostForP2P,
@Named(NetworkOptionKeys.PORT_KEY) int port,
@Named(NetworkOptionKeys.TOR_DIR) File torDir,
@Named(Config.TOR_DIR) File torDir,
@Named(NetworkOptionKeys.TORRC_FILE) String torrcFile,
@Named(NetworkOptionKeys.TORRC_OPTIONS) String torrcOptions,
@Named(NetworkOptionKeys.EXTERNAL_TOR_CONTROL_PORT) String controlPort,

View file

@ -46,6 +46,7 @@ import java.time.Clock;
import java.io.File;
import static bisq.common.config.Config.TOR_DIR;
import static com.google.inject.name.Names.named;
public class P2PModule extends AppModule {
@ -78,8 +79,7 @@ public class P2PModule extends AppModule {
Boolean useLocalhostForP2P = environment.getProperty(NetworkOptionKeys.USE_LOCALHOST_FOR_P2P, boolean.class, false);
bind(boolean.class).annotatedWith(Names.named(NetworkOptionKeys.USE_LOCALHOST_FOR_P2P)).toInstance(useLocalhostForP2P);
File torDir = new File(environment.getRequiredProperty(NetworkOptionKeys.TOR_DIR));
bind(File.class).annotatedWith(named(NetworkOptionKeys.TOR_DIR)).toInstance(torDir);
bind(File.class).annotatedWith(named(TOR_DIR)).toInstance(config.getTorDir());
// use a fixed port as arbitrator use that for his ID
Integer port = environment.getProperty(NetworkOptionKeys.PORT_KEY, int.class, 9999);

View file

@ -20,6 +20,7 @@ package bisq.network.p2p.storage.persistence;
import bisq.network.p2p.storage.P2PDataStorage;
import bisq.network.p2p.storage.payload.PersistableNetworkPayload;
import bisq.common.config.Config;
import bisq.common.storage.FileUtil;
import bisq.common.storage.Storage;
@ -53,7 +54,7 @@ public final class PersistableNetworkPayloadListService extends MapStoreService<
///////////////////////////////////////////////////////////////////////////////////////////
@Inject
public PersistableNetworkPayloadListService(@Named(Storage.STORAGE_DIR) File storageDir,
public PersistableNetworkPayloadListService(@Named(Config.STORAGE_DIR) File storageDir,
Storage<PersistableNetworkPayloadList> persistableNetworkPayloadMapStorage) {
super(storageDir, persistableNetworkPayloadMapStorage);
}