Browse Source

Fix ApiService to use new org.qora.* package names

Also add missing default for blockchain config file to Settings
pull/67/head
catbref 6 years ago
parent
commit
17f3958ad6
  1. 1
      .settings/org.eclipse.core.resources.prefs
  2. 2
      src/main/java/org/qora/api/ApiService.java
  3. 34
      src/main/java/org/qora/settings/Settings.java

1
.settings/org.eclipse.core.resources.prefs

@ -2,6 +2,5 @@ eclipse.preferences.version=1
encoding//src/main/java=UTF-8
encoding//src/main/resources=UTF-8
encoding//src/test/java=UTF-8
encoding//target/generated-sources/package-info=UTF-8
encoding/<project>=UTF-8
encoding/src=UTF-8

2
src/main/java/org/qora/api/ApiService.java

@ -25,7 +25,7 @@ public class ApiService {
public ApiService() {
config = new ResourceConfig();
config.packages("api.resource");
config.packages("org.qora.api.resource");
config.register(OpenApiResource.class);
config.register(ApiDefinition.class);
config.register(AnnotationPostProcessor.class);

34
src/main/java/org/qora/settings/Settings.java

@ -27,6 +27,7 @@ public class Settings {
private String userpath = "";
private boolean useBitcoinTestNet = false;
private boolean wipeUnconfirmedOnStart = true;
private String blockchainConfigPath = "blockchain.json";
// RPC
private int rpcPort = 9085;
@ -132,27 +133,26 @@ public class Settings {
// Blockchain config
if (json.containsKey("wipeUnconfirmedOnStart")) {
if (json.containsKey("wipeUnconfirmedOnStart"))
this.wipeUnconfirmedOnStart = (Boolean) getTypedJson(json, "wipeUnconfirmedOnStart", Boolean.class);
}
if (json.containsKey("blockchainConfig")) {
String filename = (String) json.get("blockchainConfig");
File file = new File(this.userpath + filename);
if (json.containsKey("blockchainConfig"))
blockchainConfigPath = (String) getTypedJson(json, "blockchainConfig", String.class);
if (!file.exists()) {
LOGGER.info("Blockchain config file not found: " + this.userpath + filename);
throw new RuntimeException("Unable to read blockchain config file");
}
File file = new File(this.userpath + blockchainConfigPath);
try {
List<String> lines = Files.readLines(file, Charsets.UTF_8);
JSONObject blockchainJSON = (JSONObject) JSONValue.parse(String.join("\n", lines));
BlockChain.fromJSON(blockchainJSON);
} catch (IOException e) {
LOGGER.error("Unable to parse blockchain config file: " + this.userpath + filename);
throw new RuntimeException("Unable to parse blockchain config file", e);
}
if (!file.exists()) {
LOGGER.info("Blockchain config file not found: " + this.userpath + blockchainConfigPath);
throw new RuntimeException("Unable to read blockchain config file");
}
try {
List<String> lines = Files.readLines(file, Charsets.UTF_8);
JSONObject blockchainJSON = (JSONObject) JSONValue.parse(String.join("\n", lines));
BlockChain.fromJSON(blockchainJSON);
} catch (IOException e) {
LOGGER.error("Unable to parse blockchain config file: " + this.userpath + blockchainConfigPath);
throw new RuntimeException("Unable to parse blockchain config file", e);
}
}

Loading…
Cancel
Save