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);
}
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();
}
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();
}
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();
}
}
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);
}
Aggregations