use of io.nuls.network.rpc.model.NetworkInfoDto in project nuls by nuls-io.
the class NetworkResource method getNetworkInfo.
// private NodeCacheManager nodeCacheManager = NodeCacheManager.getInstance();
@GET
@Path("/info/")
@Produces(MediaType.APPLICATION_JSON)
@ApiOperation(value = "查询网络最新信息")
@ApiResponses(value = { @ApiResponse(code = 200, message = "success", response = NetworkInfoDto.class) })
public RpcClientResult getNetworkInfo() {
NetworkInfoDto info = new NetworkInfoDto(NulsContext.getInstance().getBestBlock().getHeader().getHeight(), NulsContext.getInstance().getNetBestBlockHeight(), TimeService.getNetTimeOffset());
Collection<Node> collections = networkService.getAvailableNodes();
int inCount = 0;
int outCount = 0;
for (Node node : collections) {
if (node.getType() == Node.IN) {
inCount++;
} else {
outCount++;
}
}
info.setInCount(inCount);
info.setOutCount(outCount);
info.setMastUpGrade(NulsContext.mastUpGrade);
Result result = Result.getSuccess();
result.setData(info);
return result.toRpcClientResult();
}
Aggregations