3 import com.google.gson.annotations.SerializedName;
4 import io.bytom.common.Utils;
5 import io.bytom.exception.BytomException;
6 import io.bytom.http.Client;
7 import org.apache.log4j.Logger;
9 public class CoreConfig {
12 private static Logger logger = Logger.getLogger(CoreConfig.class);
19 * @throws BytomException
21 public static NetInfo getNetInfo(Client client) throws BytomException {
22 NetInfo netInfo = client.request("net-info", null, NetInfo.class);
24 logger.info("net-info:");
25 logger.info(netInfo.toJson());
35 * @throws BytomException
37 public static Integer getGasRate(Client client) throws BytomException {
38 Integer gas = client.requestGet("gas-rate", null, "gas_rate", Integer.class);
40 logger.info("gas-rate:");
46 public static class NetInfo {
48 * listening, whether the node is listening.
50 public boolean listening;
53 * syncing, whether the node is syncing.
55 public boolean syncing;
58 * mining, whether the node is mining.
60 public boolean mining;
63 * nodeXPub, the node xpub.
65 @SerializedName("node_xpub")
66 public String nodeXPub;
69 * peer_count, current count of connected peers.
71 @SerializedName("peer_count")
75 * current_block, current block height in the node's blockchain.
77 @SerializedName("current_block")
78 public long currentBlock;
81 * highest_block, current highest block of the connected peers.
83 @SerializedName("highest_block")
84 public long highestBlock;
87 * finalized_block, finalized block of the connected peers.
89 @SerializedName("finalized_block")
90 public long finalizedBlock;
93 * network_id, network id.
95 @SerializedName("network_id")
96 public String networkID;
99 * version, bytom version.
101 @SerializedName("version")
102 public String version;
104 public String toJson() {
105 return Utils.serializer.toJson(this);