use of io.nuls.rpc.entity.InfoDto in project nuls by nuls-io.
the class NetworkMessageResource method getInfo.
@GET
@Path("/info")
@Produces(MediaType.APPLICATION_JSON)
public RpcResult getInfo() {
RpcResult result = RpcResult.getSuccess();
InfoDto info = new InfoDto(NulsContext.getInstance().getBestBlock().getHeader().getHeight(), NulsContext.getInstance().getNetBestBlockHeight(), TimeService.getNetTimeOffset());
NodeGroup inGroup = networkService.getNodeGroup(NetworkConstant.NETWORK_NODE_IN_GROUP);
NodeGroup outGroup = networkService.getNodeGroup(NetworkConstant.NETWORK_NODE_OUT_GROUP);
int count = 0;
for (Node node : inGroup.getNodes().values()) {
if (node.getStatus() == Node.HANDSHAKE) {
count += 1;
}
}
info.setInCount(count);
count = 0;
for (Node node : outGroup.getNodes().values()) {
if (node.getStatus() == Node.HANDSHAKE) {
count += 1;
}
}
info.setOutCount(count);
result.setData(info);
return result;
}