use of io.nuls.rpc.entity.RpcResult in project nuls by nuls-io.
the class SystemResource method startModule.
@POST
@Path("/module/load")
@Produces(MediaType.APPLICATION_JSON)
public RpcResult startModule(@FormParam("moduleName") String moduleName, @FormParam("moduleClass") String moduleClass) {
// todo change the params to a form entity
RpcResult result = null;
do {
ModuleService service = ModuleService.getInstance();
AssertUtil.canNotEmpty(service, "System module service error!");
try {
service.startModule(moduleName, moduleClass);
} catch (IllegalAccessException e) {
Log.error(e);
break;
} catch (InstantiationException e) {
Log.error(e);
break;
} catch (ClassNotFoundException e) {
Log.error(e);
break;
}
result = RpcResult.getSuccess();
} while (false);
return result;
}
use of io.nuls.rpc.entity.RpcResult in project nuls by nuls-io.
the class TransactionResource method list.
@GET
@Path("/locked")
@Produces(MediaType.APPLICATION_JSON)
public RpcResult list(@QueryParam("address") String address, @QueryParam("pageNumber") int pageNumber, @QueryParam("pageSize") int pageSize) {
if (!Address.validAddress(address)) {
return RpcResult.getFailed(ErrorCode.PARAMETER_ERROR);
}
if (pageNumber < 0 || pageSize < 0) {
return RpcResult.getFailed(ErrorCode.PARAMETER_ERROR);
}
if (pageNumber == 0) {
pageNumber = 1;
}
if (pageSize == 0) {
pageSize = 10;
}
// todo ledgerService.getLockUtxo
List<UtxoOutputPo> poList = outputDataService.getLockUtxo(address, TimeService.currentTimeMillis(), pageNumber, pageSize);
List<OutputDto> dtoList = new ArrayList<>();
for (UtxoOutputPo po : poList) {
dtoList.add(new OutputDto(po));
}
RpcResult result = RpcResult.getSuccess();
result.setData(dtoList);
return result;
}
use of io.nuls.rpc.entity.RpcResult in project nuls by nuls-io.
the class TransactionResource method load.
@GET
@Path("/hash/{hash}")
@Produces(MediaType.APPLICATION_JSON)
public RpcResult load(@PathParam("hash") String hash) {
RpcResult result = null;
if (StringUtils.isBlank(hash)) {
return RpcResult.getFailed(ErrorCode.NULL_PARAMETER);
}
try {
Transaction tx = ledgerService.getTx(NulsDigestData.fromDigestHex(hash));
if (tx == null) {
result = RpcResult.getFailed("not found");
} else {
result = RpcResult.getSuccess();
result.setData(new TransactionDto(tx));
}
} catch (NulsRuntimeException re) {
Log.error(re);
result = new RpcResult(false, re.getCode(), re.getMessage());
} catch (Exception e) {
Log.error(e);
result = RpcResult.getFailed(ErrorCode.SYS_UNKOWN_EXCEPTION);
}
return result;
}
use of io.nuls.rpc.entity.RpcResult in project nuls by nuls-io.
the class BlockResource method getHeader.
@GET
@Path("/header/hash/{hash}")
@Produces(MediaType.APPLICATION_JSON)
public RpcResult getHeader(@PathParam("hash") String hash) throws NulsException, IOException {
RpcResult result = RpcResult.getSuccess();
BlockHeader blockHeader = blockService.getBlockHeader(hash);
if (blockHeader == null) {
return RpcResult.getFailed(ErrorCode.DATA_NOT_FOUND);
}
long reward = ledgerService.getBlockReward(blockHeader.getHeight());
long fee = ledgerService.getBlockFee(blockHeader.getHeight());
result.setData(new BlockDto(blockHeader, reward, fee));
return result;
}
use of io.nuls.rpc.entity.RpcResult in project nuls by nuls-io.
the class BlockResource method getHeaderByHeight.
@GET
@Path("/header/height/{height}")
@Produces(MediaType.APPLICATION_JSON)
public RpcResult getHeaderByHeight(@PathParam("height") Integer height) throws NulsException, IOException {
RpcResult result = RpcResult.getSuccess();
BlockHeader blockHeader = blockService.getBlockHeader(height);
if (blockHeader == null) {
return RpcResult.getFailed(ErrorCode.DATA_NOT_FOUND);
}
long reward = ledgerService.getBlockReward(blockHeader.getHeight());
long fee = ledgerService.getBlockFee(blockHeader.getHeight());
result.setData(new BlockDto(blockHeader, reward, fee));
return result;
}
Aggregations