mirror of
https://github.com/bisq-network/bisq.git
synced 2025-02-24 07:07:43 +01:00
Move 'genesisBlockHeight' option handling to Config
This commit is contained in:
parent
6ea146444f
commit
ca5b260806
6 changed files with 18 additions and 12 deletions
|
@ -73,6 +73,7 @@ public class Config {
|
||||||
public static final String DUMP_BLOCKCHAIN_DATA = "dumpBlockchainData";
|
public static final String DUMP_BLOCKCHAIN_DATA = "dumpBlockchainData";
|
||||||
public static final String FULL_DAO_NODE = "fullDaoNode";
|
public static final String FULL_DAO_NODE = "fullDaoNode";
|
||||||
public static final String GENESIS_TX_ID = "genesisTxId";
|
public static final String GENESIS_TX_ID = "genesisTxId";
|
||||||
|
public static final String GENESIS_BLOCK_HEIGHT = "genesisBlockHeight";
|
||||||
|
|
||||||
private static final Logger log = LoggerFactory.getLogger(Config.class);
|
private static final Logger log = LoggerFactory.getLogger(Config.class);
|
||||||
|
|
||||||
|
@ -144,6 +145,7 @@ public class Config {
|
||||||
private final boolean fullDaoNode;
|
private final boolean fullDaoNode;
|
||||||
private final boolean fullDaoNodeOptionSetExplicitly;
|
private final boolean fullDaoNodeOptionSetExplicitly;
|
||||||
private final String genesisTxId;
|
private final String genesisTxId;
|
||||||
|
private final int genesisBlockHeight;
|
||||||
|
|
||||||
// properties derived from cli options, but not exposed as cli options themselves
|
// properties derived from cli options, but not exposed as cli options themselves
|
||||||
private boolean localBitcoinNodeIsRunning = false; // FIXME: eliminate mutable state
|
private boolean localBitcoinNodeIsRunning = false; // FIXME: eliminate mutable state
|
||||||
|
@ -504,6 +506,13 @@ public class Config {
|
||||||
.withRequiredArg()
|
.withRequiredArg()
|
||||||
.defaultsTo("");
|
.defaultsTo("");
|
||||||
|
|
||||||
|
ArgumentAcceptingOptionSpec<Integer> genesisBlockHeightOpt =
|
||||||
|
parser.accepts(GENESIS_BLOCK_HEIGHT,
|
||||||
|
"Genesis transaction block height when not using the hard coded one")
|
||||||
|
.withRequiredArg()
|
||||||
|
.ofType(int.class)
|
||||||
|
.defaultsTo(-1);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
OptionSet cliOpts = parser.parse(args);
|
OptionSet cliOpts = parser.parse(args);
|
||||||
|
|
||||||
|
@ -600,6 +609,7 @@ public class Config {
|
||||||
this.fullDaoNode = options.valueOf(fullDaoNodeOpt);
|
this.fullDaoNode = options.valueOf(fullDaoNodeOpt);
|
||||||
this.fullDaoNodeOptionSetExplicitly = options.has(fullDaoNodeOpt);
|
this.fullDaoNodeOptionSetExplicitly = options.has(fullDaoNodeOpt);
|
||||||
this.genesisTxId = options.valueOf(genesisTxIdOpt);
|
this.genesisTxId = options.valueOf(genesisTxIdOpt);
|
||||||
|
this.genesisBlockHeight = options.valueOf(genesisBlockHeightOpt);
|
||||||
} catch (OptionException ex) {
|
} catch (OptionException ex) {
|
||||||
throw new ConfigException(format("problem parsing option '%s': %s",
|
throw new ConfigException(format("problem parsing option '%s': %s",
|
||||||
ex.options().get(0),
|
ex.options().get(0),
|
||||||
|
@ -899,4 +909,8 @@ public class Config {
|
||||||
public String getGenesisTxId() {
|
public String getGenesisTxId() {
|
||||||
return genesisTxId;
|
return genesisTxId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getGenesisBlockHeight() {
|
||||||
|
return genesisBlockHeight;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,6 +20,7 @@ package bisq.core.app;
|
||||||
import bisq.core.dao.DaoOptionKeys;
|
import bisq.core.dao.DaoOptionKeys;
|
||||||
|
|
||||||
import bisq.common.BisqException;
|
import bisq.common.BisqException;
|
||||||
|
import bisq.common.config.Config;
|
||||||
|
|
||||||
import org.springframework.core.env.JOptCommandLinePropertySource;
|
import org.springframework.core.env.JOptCommandLinePropertySource;
|
||||||
import org.springframework.core.env.MutablePropertySources;
|
import org.springframework.core.env.MutablePropertySources;
|
||||||
|
@ -57,7 +58,7 @@ public class BisqEnvironment extends StandardEnvironment {
|
||||||
protected boolean isBitcoinLocalhostNodeRunning;
|
protected boolean isBitcoinLocalhostNodeRunning;
|
||||||
|
|
||||||
protected final String
|
protected final String
|
||||||
genesisBlockHeight, genesisTotalSupply,
|
genesisTotalSupply,
|
||||||
daoActivated;
|
daoActivated;
|
||||||
|
|
||||||
public BisqEnvironment(OptionSet options) {
|
public BisqEnvironment(OptionSet options) {
|
||||||
|
@ -68,7 +69,6 @@ public class BisqEnvironment extends StandardEnvironment {
|
||||||
@SuppressWarnings("ConstantConditions")
|
@SuppressWarnings("ConstantConditions")
|
||||||
public BisqEnvironment(PropertySource commandLineProperties) {
|
public BisqEnvironment(PropertySource commandLineProperties) {
|
||||||
//DaoOptionKeys
|
//DaoOptionKeys
|
||||||
genesisBlockHeight = getProperty(commandLineProperties, DaoOptionKeys.GENESIS_BLOCK_HEIGHT, "-1");
|
|
||||||
genesisTotalSupply = getProperty(commandLineProperties, DaoOptionKeys.GENESIS_TOTAL_SUPPLY, "-1");
|
genesisTotalSupply = getProperty(commandLineProperties, DaoOptionKeys.GENESIS_TOTAL_SUPPLY, "-1");
|
||||||
daoActivated = getProperty(commandLineProperties, DaoOptionKeys.DAO_ACTIVATED, "true");
|
daoActivated = getProperty(commandLineProperties, DaoOptionKeys.DAO_ACTIVATED, "true");
|
||||||
|
|
||||||
|
@ -88,7 +88,6 @@ public class BisqEnvironment extends StandardEnvironment {
|
||||||
private PropertySource<?> defaultProperties() {
|
private PropertySource<?> defaultProperties() {
|
||||||
return new PropertiesPropertySource(BISQ_DEFAULT_PROPERTY_SOURCE_NAME, new Properties() {
|
return new PropertiesPropertySource(BISQ_DEFAULT_PROPERTY_SOURCE_NAME, new Properties() {
|
||||||
{
|
{
|
||||||
setProperty(DaoOptionKeys.GENESIS_BLOCK_HEIGHT, genesisBlockHeight);
|
|
||||||
setProperty(DaoOptionKeys.GENESIS_TOTAL_SUPPLY, genesisTotalSupply);
|
setProperty(DaoOptionKeys.GENESIS_TOTAL_SUPPLY, genesisTotalSupply);
|
||||||
setProperty(DaoOptionKeys.DAO_ACTIVATED, daoActivated);
|
setProperty(DaoOptionKeys.DAO_ACTIVATED, daoActivated);
|
||||||
}
|
}
|
||||||
|
|
|
@ -285,10 +285,6 @@ public abstract class BisqExecutable implements GracefulShutDownHandler, BisqSet
|
||||||
.ofType(boolean.class);
|
.ofType(boolean.class);
|
||||||
|
|
||||||
//RpcOptionKeys
|
//RpcOptionKeys
|
||||||
parser.accepts(DaoOptionKeys.GENESIS_BLOCK_HEIGHT,
|
|
||||||
format("Genesis transaction block height when not using the hard coded one (default: %s)", "-1"))
|
|
||||||
.withRequiredArg();
|
|
||||||
|
|
||||||
parser.accepts(DaoOptionKeys.GENESIS_TOTAL_SUPPLY,
|
parser.accepts(DaoOptionKeys.GENESIS_TOTAL_SUPPLY,
|
||||||
format("Genesis total supply when not using the hard coded one (default: %s)", "-1"))
|
format("Genesis total supply when not using the hard coded one (default: %s)", "-1"))
|
||||||
.withRequiredArg();
|
.withRequiredArg();
|
||||||
|
|
|
@ -199,9 +199,7 @@ public class DaoModule extends AppModule {
|
||||||
|
|
||||||
// Genesis
|
// Genesis
|
||||||
bindConstant().annotatedWith(named(Config.GENESIS_TX_ID)).to(config.getGenesisTxId());
|
bindConstant().annotatedWith(named(Config.GENESIS_TX_ID)).to(config.getGenesisTxId());
|
||||||
|
bindConstant().annotatedWith(named(Config.GENESIS_BLOCK_HEIGHT)).to(config.getGenesisBlockHeight());
|
||||||
Integer genesisBlockHeight = environment.getProperty(DaoOptionKeys.GENESIS_BLOCK_HEIGHT, Integer.class, -1);
|
|
||||||
bind(Integer.class).annotatedWith(Names.named(DaoOptionKeys.GENESIS_BLOCK_HEIGHT)).toInstance(genesisBlockHeight);
|
|
||||||
|
|
||||||
Long genesisTotalSupply = environment.getProperty(DaoOptionKeys.GENESIS_TOTAL_SUPPLY, Long.class, -1L);
|
Long genesisTotalSupply = environment.getProperty(DaoOptionKeys.GENESIS_TOTAL_SUPPLY, Long.class, -1L);
|
||||||
bind(Long.class).annotatedWith(Names.named(DaoOptionKeys.GENESIS_TOTAL_SUPPLY)).toInstance(genesisTotalSupply);
|
bind(Long.class).annotatedWith(Names.named(DaoOptionKeys.GENESIS_TOTAL_SUPPLY)).toInstance(genesisTotalSupply);
|
||||||
|
|
|
@ -22,7 +22,6 @@ package bisq.core.dao;
|
||||||
*/
|
*/
|
||||||
public class DaoOptionKeys {
|
public class DaoOptionKeys {
|
||||||
|
|
||||||
public static final String GENESIS_BLOCK_HEIGHT = "genesisBlockHeight";
|
|
||||||
public static final String GENESIS_TOTAL_SUPPLY = "genesisTotalSupply";
|
public static final String GENESIS_TOTAL_SUPPLY = "genesisTotalSupply";
|
||||||
public static final String DAO_ACTIVATED = "daoActivated";
|
public static final String DAO_ACTIVATED = "daoActivated";
|
||||||
}
|
}
|
||||||
|
|
|
@ -106,7 +106,7 @@ public class GenesisTxInfo {
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public GenesisTxInfo(@Named(Config.GENESIS_TX_ID) String genesisTxId,
|
public GenesisTxInfo(@Named(Config.GENESIS_TX_ID) String genesisTxId,
|
||||||
@Named(DaoOptionKeys.GENESIS_BLOCK_HEIGHT) Integer genesisBlockHeight,
|
@Named(Config.GENESIS_BLOCK_HEIGHT) int genesisBlockHeight,
|
||||||
@Named(DaoOptionKeys.GENESIS_TOTAL_SUPPLY) Long genesisTotalSupply) {
|
@Named(DaoOptionKeys.GENESIS_TOTAL_SUPPLY) Long genesisTotalSupply) {
|
||||||
BaseCurrencyNetwork baseCurrencyNetwork = BaseCurrencyNetwork.CURRENT_NETWORK;
|
BaseCurrencyNetwork baseCurrencyNetwork = BaseCurrencyNetwork.CURRENT_NETWORK;
|
||||||
boolean isMainnet = baseCurrencyNetwork.isMainnet();
|
boolean isMainnet = baseCurrencyNetwork.isMainnet();
|
||||||
|
|
Loading…
Add table
Reference in a new issue