use of io.nuls.rpc.entity.RpcResult in project nuls by nuls-io.
the class PocConsensusResource method getAgentListByDepositAddress.
@GET
@Path("/agent/address/{address}")
@Produces(MediaType.APPLICATION_JSON)
public RpcResult getAgentListByDepositAddress(@QueryParam("pageNumber") Integer pageNumber, @QueryParam("pageSize") Integer pageSize, @PathParam("address") String address) {
RpcResult result = RpcResult.getSuccess();
if (null == pageNumber || pageNumber == 0) {
pageNumber = 1;
}
if (null == pageSize || pageSize == 0) {
pageSize = 10;
}
if (pageNumber < 0 || pageSize < 0 || pageSize > 100) {
return RpcResult.getFailed(ErrorCode.PARAMETER_ERROR);
}
// Page<AgentInfo> listPage = new Page<>();
// if (temp == 1) {
// listPage.setPageNumber(pageNumber);
// listPage.setPageSize(pageSize);
// listPage.setTotal(pageSize * 3);
// listPage.setPages(3);
// List<AgentInfo> list = new ArrayList<>();
// for (int i = 0; i < pageSize; i++) {
// AgentInfo item = new AgentInfo();
// item.setCommissionRate(15);
// item.setCreditRatio(0.9);
// item.setStatus(2);
// item.setAgentId(StringUtils.getNewUUID());
// item.setMemberCount(3 + pageNumber);
// item.setOwndeposit(Na.parseNuls(50000 + pageNumber));
// item.setTotalDeposit(Na.parseNuls(300000 + pageNumber));
// item.setIntroduction("哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈" + pageNumber);
// item.setAgentAddress("2CYdNLysoMbPRc4Q5YsVreT99Q61ZSg");
// item.setAgentName("超级节点" + i + pageNumber);
// item.setStartTime(System.currentTimeMillis());
// item.setPackedCount(11234 + i * pageNumber);
// item.setReward(Na.parseNuls(1120 * i + pageNumber));
// list.add(item);
// }
// listPage.setList(list);
// result.setData(listPage);
// return result;
// }
Page<Map<String, Object>> list = this.consensusService.getAgentList(null, address, null, null, pageNumber, pageSize);
result.setData(list);
return result;
}
use of io.nuls.rpc.entity.RpcResult in project nuls by nuls-io.
the class PocConsensusResource method queryDepositListByAgentAddress.
@GET
@Path("/deposit/agent/{agentAddress}")
@Produces(MediaType.APPLICATION_JSON)
public RpcResult queryDepositListByAgentAddress(@PathParam("agentAddress") String agentAddress, @QueryParam("pageNumber") Integer pageNumber, @QueryParam("pageSize") Integer pageSize) {
AssertUtil.canNotEmpty(agentAddress);
if (null == pageNumber || pageNumber == 0) {
pageNumber = 1;
}
if (null == pageSize || pageSize == 0) {
pageSize = 10;
}
if (pageNumber < 0 || pageSize < 0 || pageSize > 100) {
return RpcResult.getFailed(ErrorCode.PARAMETER_ERROR);
}
RpcResult result = RpcResult.getSuccess();
// Page<DepositItem> listPage = new Page<>();
// if (temp == 1) {
// listPage.setPageNumber(pageNumber);
// listPage.setPageSize(pageSize);
// listPage.setTotal(pageSize * 3);
// listPage.setPages(3);
// List<DepositItem> list = new ArrayList<>();
// for (int i = 0; i < pageSize; i++) {
// DepositItem item = new DepositItem();
// try {
// item.setAddress(AccountTool.createAccount().getAddress().toString());
// } catch (NulsException e) {
// Log.error(e);
// }
// item.setAgentName("二货节点" + i);
// item.setAmount(100000000 + i);
// item.setDepositTime(System.currentTimeMillis());
// item.setStatus(i / 2);
// item.setAgentAddress(agentAddress);
// list.add(item);
// }
// listPage.setList(list);
// result.setData(listPage);
// return result;
// }
Page<Map<String, Object>> page = this.consensusService.getDepositList(null, agentAddress, pageNumber, pageSize);
result.setData(page);
return result;
}
use of io.nuls.rpc.entity.RpcResult in project nuls by nuls-io.
the class PocConsensusResource method getDepositListByAddress.
@GET
@Path("/deposit/address/{address}")
@Produces(MediaType.APPLICATION_JSON)
public RpcResult getDepositListByAddress(@PathParam("address") String address, @QueryParam("pageNumber") Integer pageNumber, @QueryParam("pageSize") Integer pageSize, @QueryParam("agentAddress") String agentAddress) {
AssertUtil.canNotEmpty(address);
if (null == pageNumber || pageNumber == 0) {
pageNumber = 1;
}
if (null == pageSize || pageSize == 0) {
pageSize = 10;
}
if (pageNumber < 0 || pageSize < 0 || pageSize > 100) {
return RpcResult.getFailed(ErrorCode.PARAMETER_ERROR);
}
RpcResult result = RpcResult.getSuccess();
// Page<DepositItem> listPage = new Page<>();
// if (temp == 1) {
// listPage.setPageNumber(pageNumber);
// listPage.setPageSize(pageSize);
// listPage.setTotal(pageSize * 3);
// listPage.setPages(3);
// List<DepositItem> list = new ArrayList<>();
// for (int i = 0; i < pageSize; i++) {
// DepositItem item = new DepositItem();
// item.setAddress(address);
// item.setAmount(1000000000);
// item.setDepositTime(System.currentTimeMillis());
// item.setStatus(2);
// item.setAgentName("二货节点" + i);
// if (StringUtils.isNotBlank(agentAddress)) {
// item.setAgentAddress(agentAddress);
// } else {
// try {
// item.setAgentAddress(AccountTool.createAccount().getAddress().toString());
// } catch (NulsException e) {
// Log.error(e);
// }
// }
// list.add(item);
// }
// listPage.setList(list);
// result.setData(listPage);
// return result;
// }
Page<Map<String, Object>> page = this.consensusService.getDepositList(address, agentAddress, pageNumber, pageSize);
result.setData(page);
return result;
}
use of io.nuls.rpc.entity.RpcResult in project nuls by nuls-io.
the class PocConsensusResource method profit.
@GET
@Path("/profit")
@Produces(MediaType.APPLICATION_JSON)
public RpcResult profit(@QueryParam("address") String address) {
Map<String, Object> map = new HashMap<>();
if ((address != null && !Address.validAddress(address))) {
return RpcResult.getFailed(ErrorCode.PARAMETER_ERROR);
}
if (address == null) {
address = accountService.getDefaultAccount().getAddress().getBase58();
}
// get all reward
List<UtxoOutputPo> outputList = outputDataService.getAccountOutputs(TransactionConstant.TX_TYPE_COIN_BASE, address, null, null);
long value = 0;
for (UtxoOutputPo output : outputList) {
value += output.getValue();
}
map.put("profit", Na.valueOf(value).toDouble());
// get last 24 hours reward
long nowTime = TimeService.currentTimeMillis();
nowTime = nowTime - DateUtil.DATE_TIME;
outputList = outputDataService.getAccountOutputs(TransactionConstant.TX_TYPE_COIN_BASE, address, nowTime, null);
value = 0;
for (UtxoOutputPo output : outputList) {
value += output.getValue();
}
map.put("lastProfit", Na.valueOf(value).toDouble());
map.put("investment", NulsContext.INVESTMENT.toDouble());
RpcResult rpcResult = RpcResult.getSuccess();
rpcResult.setData(map);
return rpcResult;
}
use of io.nuls.rpc.entity.RpcResult in project nuls by nuls-io.
the class PocConsensusResource method getWholeInfo.
@GET
@Produces(MediaType.APPLICATION_JSON)
@ApiOperation("Get the whole network consensus infomation!")
public RpcResult getWholeInfo() {
RpcResult result = RpcResult.getSuccess();
WholeNetConsensusInfoDTO dto = new WholeNetConsensusInfoDTO();
Map<String, Object> map = this.consensusService.getConsensusInfo();
dto.setAgentCount((Integer) map.get("agentCount"));
dto.setRewardOfDay((Long) map.get("rewardOfDay"));
dto.setTotalDeposit((Long) map.get("totalDeposit"));
dto.setConsensusAccountNumber((Integer) map.get("memberCount"));
result.setData(dto);
return result;
}
Aggregations