OSDN Git Service

add generateClient method to Client class
authorsuccessli <successli@outlook.com>
Thu, 31 May 2018 05:51:53 +0000 (13:51 +0800)
committersuccessli <successli@outlook.com>
Thu, 31 May 2018 05:51:53 +0000 (13:51 +0800)
src/main/java/io/bytom/http/Client.java

index 3dda915..9f3b1a1 100644 (file)
@@ -41,7 +41,7 @@ public class Client {
     private OkHttpClient httpClient;
 
     // Used to create empty, in-memory key stores.
-    private static final char[] DEFAULT_KEYSTORE_PASSWORD = "password".toCharArray();
+    private static final char[] DEFAULT_KEYSTORE_PASSWORD = "123456".toCharArray();
     private static final MediaType JSON = MediaType.parse("application/json; charset=utf-8");
     private static String version = "dev"; // updated in the static initializer
 
@@ -57,6 +57,18 @@ public class Client {
         }
     }
 
+    public static Client generateClient() throws BytomException {
+
+        String coreURL = Configuration.getValue("bytom.api.url");
+        String accessToken = Configuration.getValue("client.access.token");
+
+        if (coreURL == null || coreURL.isEmpty()) {
+            coreURL = "http://127.0.0.1:9888/";
+        }
+
+        return new Client(coreURL, accessToken);
+    }
+
     public Client(Builder builder) throws ConfigurationException {
         this.url = builder.url;
         this.accessToken = builder.accessToken;