Search in sources :

Example 1 with CfgNet

use of org.aion.zero.impl.config.CfgNet in project aion by aionnetwork.

the class ApiWeb3Aion method configNet.

// TODO: we can refactor these in the future to be in
// their respective classes, for now put the toJson here
private static JSONObject configNet() {
    CfgNet config = CfgAion.inst().getNet();
    JSONObject obj = new JSONObject();
    // begin base.net.p2p
    CfgNetP2p configP2p = config.getP2p();
    JSONObject p2p = new JSONObject();
    p2p.put("ip", configP2p.getIp());
    p2p.put("port", configP2p.getPort());
    p2p.put("discover", configP2p.getDiscover());
    p2p.put("errorTolerance", configP2p.getErrorTolerance());
    p2p.put("maxActiveNodes", configP2p.getMaxActiveNodes());
    p2p.put("maxTempNodes", configP2p.getMaxTempNodes());
    p2p.put("clusterNodeMode", configP2p.inClusterNodeMode());
    p2p.put("syncOnlyMode", configP2p.inSyncOnlyMode());
    // end
    obj.put("p2p", p2p);
    // begin base.net.nodes[]
    JSONArray nodeArray = new JSONArray();
    for (String n : config.getNodes()) {
        nodeArray.put(n);
    }
    // end
    obj.put("nodes", nodeArray);
    // begin base
    obj.put("id", config.getId());
    // end
    return obj;
}
Also used : JSONObject(org.json.JSONObject) CfgNetP2p(org.aion.zero.impl.config.CfgNetP2p) JSONArray(org.json.JSONArray) CfgNet(org.aion.zero.impl.config.CfgNet) Hex.toHexString(org.aion.util.conversions.Hex.toHexString)

Aggregations

Hex.toHexString (org.aion.util.conversions.Hex.toHexString)1 CfgNet (org.aion.zero.impl.config.CfgNet)1 CfgNetP2p (org.aion.zero.impl.config.CfgNetP2p)1 JSONArray (org.json.JSONArray)1 JSONObject (org.json.JSONObject)1