Search in sources :

Example 66 with RpcClientResult

use of io.nuls.kernel.model.RpcClientResult in project nuls by nuls-io.

the class UpgradeProcessor method execute.

@Override
public CommandResult execute(String[] args) {
    RpcClientResult result = restFul.post("/client/upgrade/" + args[1], "");
    if (result.isFailed()) {
        return CommandResult.getFailed(result);
    }
    // todo 打印进度,完成时确认重启
    int count = 0;
    while (true) {
        result = restFul.get("/client/upgrade", null);
        if (result.isFailed()) {
            return CommandResult.getFailed(result);
        }
        int percentage = (int) ((Map) result.getData()).get("percentage");
        // todo 打印
        print(percentage + "%", count);
        if (percentage < 10) {
            count = 2;
        } else {
            count = 3;
        }
        if (percentage == 100) {
            break;
        }
        try {
            Thread.sleep(500L);
        } catch (InterruptedException e) {
            Log.error(e.getMessage());
        }
    }
    result = restFul.post("/client/restart", "");
    return CommandResult.getResult(result);
}
Also used : RpcClientResult(io.nuls.kernel.model.RpcClientResult)

Example 67 with RpcClientResult

use of io.nuls.kernel.model.RpcClientResult in project nuls by nuls-io.

the class SimpleTransferTest method sign.

private String sign(String txHex) {
    Map<String, Object> paramsSign = new HashMap<>();
    paramsSign.put("txHex", txHex);
    paramsSign.put("address", from);
    paramsSign.put("priKey", fromKey);
    paramsSign.put("password", null);
    RpcClientResult postSign = restFul.post("/accountledger/transaction/sign", paramsSign);
    Object dataSign = postSign.getData();
    Map<String, Object> mapSign = (Map<String, Object>) dataSign;
    Object txHexSign = mapSign.get("value");
    return txHexSign.toString();
}
Also used : RpcClientResult(io.nuls.kernel.model.RpcClientResult)

Example 68 with RpcClientResult

use of io.nuls.kernel.model.RpcClientResult in project nuls by nuls-io.

the class SimpleTransferTest method create.

private String create() {
    Map<String, Object> params = new HashMap<>();
    params.put("address", from);
    params.put("toAddress", to);
    params.put("amount", amount);
    params.put("remark", "sdk-test");
    params.put("utxos", getUTXOs(from, 100L));
    RpcClientResult post = restFul.post("/accountledger/transaction/simple", params);
    Object data = post.getData();
    Map<String, Object> map = (Map<String, Object>) data;
    Map<String, Object> value = (Map<String, Object>) map.get("value");
    Object hash = value.get("hash");
    Object txHex = value.get("txHex");
    Object inputs = value.get("inputs");
    Object outputs = value.get("outputs");
    return txHex.toString();
}
Also used : RpcClientResult(io.nuls.kernel.model.RpcClientResult)

Example 69 with RpcClientResult

use of io.nuls.kernel.model.RpcClientResult in project nuls by nuls-io.

the class TestMain method main0.

static void main0() {
    RestFulUtils.getInstance().setServerUri("http://127.0.0.1:8001/api");
    restFul = RestFulUtils.getInstance();
    Map<String, Object> parameters = new HashMap<>();
    parameters.put("password", null);
    parameters.put("count", 100);
    RpcClientResult result = restFul.post("/account", parameters);
    if (result.isFailed()) {
        System.out.println("create fail");
    }
    Map<String, Object> map = ((Map) result.getData());
    List<String> list = (List<String>) map.get("list");
    TransferTest transferTest = new TransferTest("Nse4R5LhHSpRQqqocDmBnavi3B2HysCM", list);
    for (int i = 0; i < 1; i++) {
        Thread thread = new Thread(transferTest, "Charlie-" + i);
        thread.start();
    }
}
Also used : HashMap(java.util.HashMap) RpcClientResult(io.nuls.kernel.model.RpcClientResult) List(java.util.List)

Example 70 with RpcClientResult

use of io.nuls.kernel.model.RpcClientResult in project nuls by nuls-io.

the class TestMain method get.

static void get() {
    RestFulUtils.getInstance().setServerUri("http://127.0.0.1:8001/api");
    restFul = RestFulUtils.getInstance();
    // RpcClientResult result = restFul.get("/contract/result/0020ce2b820d15ecbe1c8c22526611336fd425522340c6246f0364dd1e784da8ed0b", null);
    // RpcClientResult result = restFul.get("/contract/balance/token/NseCWjDsXZUz1VDNskCPA1qw4ETE9xjd/Nse7ke7HXfe3uvfY1tyDHvWRao9uUKAn", null);
    RpcClientResult result = restFul.get("/contract/NseCWjDsXZUz1VDNskCPA1qw4ETE9xjd", null);
    if (result.isFailed()) {
        System.out.println("query fail");
    }
    Map<String, Object> map = ((Map) result.getData());
    System.out.println(map);
}
Also used : RpcClientResult(io.nuls.kernel.model.RpcClientResult)

Aggregations

RpcClientResult (io.nuls.kernel.model.RpcClientResult)88 HashMap (java.util.HashMap)49 Map (java.util.Map)24 Date (java.util.Date)14 List (java.util.List)14 Result (io.nuls.kernel.model.Result)7 InputDto (io.nuls.accout.ledger.rpc.dto.InputDto)5 GET (javax.ws.rs.GET)5 Path (javax.ws.rs.Path)5 Produces (javax.ws.rs.Produces)5 ApiOperation (io.swagger.annotations.ApiOperation)4 ApiResponses (io.swagger.annotations.ApiResponses)4 NulsException (io.nuls.kernel.exception.NulsException)3 Na (io.nuls.kernel.model.Na)3 Node (io.nuls.network.model.Node)3 Test (org.junit.Test)3 RandomSeedDTO (io.nuls.consensus.poc.rpc.model.RandomSeedDTO)2 Coin (io.nuls.kernel.model.Coin)2 IOException (java.io.IOException)2 AccountKeyStoreDto (io.nuls.account.rpc.model.AccountKeyStoreDto)1