OSDN Git Service

add CoreConfig class
authorsuccessli <successli@outlook.com>
Thu, 31 May 2018 02:37:05 +0000 (10:37 +0800)
committersuccessli <successli@outlook.com>
Thu, 31 May 2018 02:37:05 +0000 (10:37 +0800)
doc/index.md
src/main/java/io/bytom/api/CoreConfig.java [new file with mode: 0644]
src/main/java/io/bytom/api/NetInfo.java [deleted file]
src/test/java/io/bytom/integration/CoreConfigTest.java [moved from src/test/java/io/bytom/integration/NetInfoTest.java with 76% similarity]
src/test/java/io/bytom/integration/UTXOTest.java

index 1bcf835..1839c8f 100644 (file)
@@ -801,7 +801,7 @@ BlockHashRate getHashRate(Client client);
 ## Other API
 
 
-#### 1.netInfo
+#### 1.coreConfig
 
 ```java
 NetInfo getNetInfo(Client client);
@@ -813,7 +813,7 @@ NetInfo getNetInfo(Client client);
 
 ##### Returns
 
-- `NetInfo` - *netInfo*, a NetInfo object.
+- `NetInfo` - *coreConfig*, a NetInfo object.
 
 ----
 
diff --git a/src/main/java/io/bytom/api/CoreConfig.java b/src/main/java/io/bytom/api/CoreConfig.java
new file mode 100644 (file)
index 0000000..2166cca
--- /dev/null
@@ -0,0 +1,80 @@
+package io.bytom.api;
+
+import com.google.gson.annotations.SerializedName;
+import io.bytom.common.Utils;
+import io.bytom.exception.BytomException;
+import io.bytom.http.Client;
+import org.apache.log4j.Logger;
+
+public class CoreConfig {
+
+
+    private static Logger logger = Logger.getLogger(CoreConfig.class);
+
+    /**
+     * Call net-info api
+     *
+     * @param client
+     * @return
+     * @throws BytomException
+     */
+    public static NetInfo getNetInfo(Client client) throws BytomException {
+        NetInfo netInfo = client.request("net-info", null, NetInfo.class);
+
+        logger.info("net-info:");
+        logger.info(netInfo.toJson());
+
+        return netInfo;
+    }
+
+    public static class NetInfo {
+        /**
+         * listening, whether the node is listening.
+         */
+        public boolean listening;
+
+        /**
+         * syncing, whether the node is syncing.
+         */
+        public boolean syncing;
+
+        /**
+         * mining, whether the node is mining.
+         */
+        public boolean mining;
+
+        /**
+         * peer_count, current count of connected peers.
+         */
+        @SerializedName("peer_count")
+        public int peerCount;
+
+        /**
+         * current_block, current block height in the node's blockchain.
+         */
+        @SerializedName("current_block")
+        public long currentBlock;
+
+        /**
+         * highest_block, current highest block of the connected peers.
+         */
+        @SerializedName("highest_block")
+        public long highestBlock;
+
+        /**
+         * network_id, network id.
+         */
+        @SerializedName("network_id")
+        public String networkID;
+
+        /**
+         * version, bytom version.
+         */
+        @SerializedName("version")
+        public String version;
+
+        public String toJson() {
+            return Utils.serializer.toJson(this);
+        }
+    }
+}
diff --git a/src/main/java/io/bytom/api/NetInfo.java b/src/main/java/io/bytom/api/NetInfo.java
deleted file mode 100644 (file)
index 1331e0a..0000000
+++ /dev/null
@@ -1,76 +0,0 @@
-package io.bytom.api;
-
-import com.google.gson.annotations.SerializedName;
-import io.bytom.common.Utils;
-import io.bytom.exception.BytomException;
-import io.bytom.http.Client;
-import org.apache.log4j.Logger;
-
-public class NetInfo {
-
-    /**
-     * listening, whether the node is listening.
-     */
-    public boolean listening;
-
-    /**
-     * syncing, whether the node is syncing.
-     */
-    public boolean syncing;
-
-    /**
-     * mining, whether the node is mining.
-     */
-    public boolean mining;
-
-    /**
-     * peer_count, current count of connected peers.
-     */
-    @SerializedName("peer_count")
-    public int peerCount;
-
-    /**
-     * current_block, current block height in the node's blockchain.
-     */
-    @SerializedName("current_block")
-    public long currentBlock;
-
-    /**
-     * highest_block, current highest block of the connected peers.
-     */
-    @SerializedName("highest_block")
-    public long highestBlock;
-
-    /**
-     * network_id, network id.
-     */
-    @SerializedName("network_id")
-    public String networkID;
-
-    /**
-     * version, bytom version.
-     */
-    @SerializedName("version")
-    public String version;
-
-    private static Logger logger = Logger.getLogger(NetInfo.class);
-
-    public String toJson() {
-        return Utils.serializer.toJson(this);
-    }
-
-    /**
-     * Call net-info api
-     *
-     * @param client
-     * @return
-     * @throws BytomException
-     */
-    public static NetInfo getNetInfo(Client client) throws BytomException {
-        NetInfo netInfo = client.request("net-info", null, NetInfo.class);
-
-        logger.info("net-info:");
-        logger.info(netInfo.toJson());
-        return netInfo;
-    }
-}
@@ -1,13 +1,13 @@
 package io.bytom.integration;
 
 import io.bytom.TestUtils;
-import io.bytom.api.NetInfo;
+import io.bytom.api.CoreConfig;
 import io.bytom.exception.BytomException;
 import io.bytom.http.Client;
 import org.junit.Assert;
 import org.junit.Test;
 
-public class NetInfoTest {
+public class CoreConfigTest {
 
     static Client client;
 
@@ -19,12 +19,11 @@ public class NetInfoTest {
         }
     }
 
-    static NetInfo netInfo;
-
+    static CoreConfig.NetInfo netInfo;
 
     @Test
     public void testNetInfo() throws Exception {
-        netInfo = NetInfo.getNetInfo(client);
+        netInfo = CoreConfig.getNetInfo(client);
         Assert.assertNotNull(netInfo);
     }
 
index 2252e91..aca21dc 100644 (file)
@@ -1,7 +1,6 @@
 package io.bytom.integration;
 
 import io.bytom.TestUtils;
-import io.bytom.api.Balance;
 import io.bytom.api.UnspentOutput;
 import io.bytom.exception.BytomException;
 import io.bytom.http.Client;