use of io.nuls.kernel.model.RpcClientResult in project nuls by nuls-io.
the class CreateMultiStopAgentProcessor method execute.
@Override
public CommandResult execute(String[] args) {
String signAddress = args[2];
RpcClientResult res = CommandHelper.getPassword(signAddress, restFul);
if (!res.isSuccess()) {
return CommandResult.getFailed(res);
}
String password = (String) res.getData();
Map<String, Object> parameters = new HashMap<>(2);
parameters.put("address", args[1]);
parameters.put("signAddress", args[2]);
parameters.put("password", password);
RpcClientResult result = restFul.post("/consensus/multiAccount/agent/stopMultiAgent", parameters);
if (result.isFailed()) {
return CommandResult.getFailed(result);
}
return CommandResult.getResult(CommandResult.dataMultiTransformValue(result));
}
use of io.nuls.kernel.model.RpcClientResult in project nuls by nuls-io.
the class DepositProcessor method execute.
@Override
public CommandResult execute(String[] args) {
String address = args[1];
RpcClientResult res = CommandHelper.getPassword(address, restFul);
if (!res.isSuccess()) {
return CommandResult.getFailed(res);
}
String password = (String) res.getData();
Long amount = Na.parseNuls(args[3]).getValue();
Map<String, Object> parameters = new HashMap<>(4);
parameters.put("address", address);
parameters.put("agentHash", args[2]);
parameters.put("deposit", amount);
parameters.put("password", password);
RpcClientResult result = restFul.post("/consensus/deposit", parameters);
if (result.isFailed()) {
return CommandResult.getFailed(result);
}
return CommandResult.getResult(CommandResult.dataTransformValue(result));
}
use of io.nuls.kernel.model.RpcClientResult in project nuls by nuls-io.
the class CreateMultiSigAccountProcessor method execute.
@Override
public CommandResult execute(String[] args) {
Map<String, Object> parameters = new HashMap<>();
String pubkeysStr = args[1];
parameters.put("pubkeys", pubkeysStr.split(","));
parameters.put("m", args[2]);
RpcClientResult result = restFul.post("/account/createMultiAccount", parameters);
if (result.isFailed()) {
return CommandResult.getFailed(result);
}
return CommandResult.getResult(result);
}
use of io.nuls.kernel.model.RpcClientResult in project nuls by nuls-io.
the class ClientResource method startUpdate.
@POST
@Path("/upgrade/{version}")
@Produces(MediaType.APPLICATION_JSON)
@ApiOperation(value = "升级")
@ApiResponses(value = { @ApiResponse(code = 200, message = "success", response = Boolean.class) })
public RpcClientResult startUpdate(@PathParam("version") String version) {
AssertUtil.canNotEmpty(version);
SyncVersionRunner syncor = SyncVersionRunner.getInstance();
String newestVersion = syncor.getNewestVersion();
if (!VersionUtils.higherThan(newestVersion, NulsConfig.VERSION)) {
Result result = Result.getFailed(KernelErrorCode.NONEWVER);
return result.toRpcClientResult();
}
if (!version.equals(newestVersion)) {
Result result = Result.getFailed(KernelErrorCode.VERSION_NOT_NEWEST);
return result.toRpcClientResult();
}
URL url = ClientResource.class.getClassLoader().getResource("libs");
if (null == url) {
return Result.getFailed(KernelErrorCode.DATA_NOT_FOUND).toRpcClientResult();
}
UpgradeThread thread = UpgradeThread.getInstance();
if (thread.isUpgrading()) {
return Result.getFailed(KernelErrorCode.UPGRADING).toRpcClientResult();
}
boolean result = thread.start();
if (result) {
TaskManager.createAndRunThread((short) 1, "upgrade", thread);
Map<String, Boolean> map = new HashMap<>();
map.put("value", true);
return Result.getSuccess().setData(map).toRpcClientResult();
}
return Result.getFailed(KernelErrorCode.FAILED).toRpcClientResult();
}
use of io.nuls.kernel.model.RpcClientResult in project nuls by nuls-io.
the class RemoveAccountProcessor method execute.
@Override
public CommandResult execute(String[] args) {
String address = args[1];
RpcClientResult res = CommandHelper.getPassword(address, restFul);
if (!res.isSuccess()) {
return CommandResult.getFailed(res);
}
String password = (String) res.getData();
Map<String, Object> parameters = new HashMap<>();
parameters.put("password", password);
RpcClientResult result = restFul.post("/account/remove/" + address, parameters);
if (result.isFailed()) {
return CommandResult.getFailed(result);
}
return CommandResult.getSuccess("Success");
}
Aggregations