@Test public void getBlockBytes() { assertTrue(true); }
@GET @Path("/bytes") @Produces(MediaType.APPLICATION_JSON) public RpcClientResult getBlockBytes(@QueryParam("hash") String hash) throws IOException { Result result; if (!NulsDigestData.validHash(hash)) { return Result.getFailed(KernelErrorCode.PARAMETER_ERROR).toRpcClientResult(); } Block block = null; try { block = blockService.getBlock(NulsDigestData.fromDigestHex(hash), true).getData(); } catch (NulsException e) { Log.error(e); } if (block == null) { result = Result.getFailed(ProtocolErroeCode.BLOCK_IS_NULL); } else { result = Result.getSuccess(); Map<String, String> map = new HashMap<>(); map.put("value", Base64.getEncoder().encodeToString(block.serialize())); result.setData(map); } return result.toRpcClientResult(); }
BlockResource { @GET @Path("/bytes") @Produces(MediaType.APPLICATION_JSON) public RpcClientResult getBlockBytes(@QueryParam("hash") String hash) throws IOException { Result result; if (!NulsDigestData.validHash(hash)) { return Result.getFailed(KernelErrorCode.PARAMETER_ERROR).toRpcClientResult(); } Block block = null; try { block = blockService.getBlock(NulsDigestData.fromDigestHex(hash), true).getData(); } catch (NulsException e) { Log.error(e); } if (block == null) { result = Result.getFailed(ProtocolErroeCode.BLOCK_IS_NULL); } else { result = Result.getSuccess(); Map<String, String> map = new HashMap<>(); map.put("value", Base64.getEncoder().encodeToString(block.serialize())); result.setData(map); } return result.toRpcClientResult(); } }
BlockResource { @GET @Path("/bytes") @Produces(MediaType.APPLICATION_JSON) public RpcClientResult getBlockBytes(@QueryParam("hash") String hash) throws IOException { Result result; if (!NulsDigestData.validHash(hash)) { return Result.getFailed(KernelErrorCode.PARAMETER_ERROR).toRpcClientResult(); } Block block = null; try { block = blockService.getBlock(NulsDigestData.fromDigestHex(hash), true).getData(); } catch (NulsException e) { Log.error(e); } if (block == null) { result = Result.getFailed(ProtocolErroeCode.BLOCK_IS_NULL); } else { result = Result.getSuccess(); Map<String, String> map = new HashMap<>(); map.put("value", Base64.getEncoder().encodeToString(block.serialize())); result.setData(map); } return result.toRpcClientResult(); }  }
BlockResource { @GET @Path("/bytes") @Produces(MediaType.APPLICATION_JSON) public RpcClientResult getBlockBytes(@QueryParam("hash") String hash) throws IOException { Result result; if (!NulsDigestData.validHash(hash)) { return Result.getFailed(KernelErrorCode.PARAMETER_ERROR).toRpcClientResult(); } Block block = null; try { block = blockService.getBlock(NulsDigestData.fromDigestHex(hash), true).getData(); } catch (NulsException e) { Log.error(e); } if (block == null) { result = Result.getFailed(ProtocolErroeCode.BLOCK_IS_NULL); } else { result = Result.getSuccess(); Map<String, String> map = new HashMap<>(); map.put("value", Base64.getEncoder().encodeToString(block.serialize())); result.setData(map); } return result.toRpcClientResult(); }  @GET @Path("/header/height/{height}") @Produces(MediaType.APPLICATION_JSON) @ApiOperation(value = "根据区块高度查询区块头", notes = "result.data: blockHeaderJson 返回对应的区块头信息") @ApiResponses(value = { @ApiResponse(code = 200, message = "success", response = BlockDto.class) }) RpcClientResult getHeaderByHeight(@ApiParam(name = "height", value = "区块高度", required = true)
                                             @PathParam("height") Integer height); @GET @Path("/header/txHash/height/{height}") @Produces(MediaType.APPLICATION_JSON) @ApiOperation(value = "根据区块高度查询区块头", notes = "result.data: blockHeaderJson 返回对应的区块头信息") @ApiResponses(value = { @ApiResponse(code = 200, message = "success", response = BlockDto.class) }) RpcClientResult getHeaderHashesByHeight(@ApiParam(name = "height", value = "区块高度", required = true)
                                                   @PathParam("height") Integer height); @GET @Path("/header/hash/{hash}") @Produces(MediaType.APPLICATION_JSON) @ApiOperation(value = "根据区块hash查询区块头", notes = "result.data: blockHeaderJson 返回对应的区块头信息") @ApiResponses(value = { @ApiResponse(code = 200, message = "success", response = BlockDto.class) }) RpcClientResult getHeader(@ApiParam(name = "hash", value = "区块hash", required = true)
                                     @PathParam("hash") String hash); @GET @Path("/header/txHash/hash/{hash}") @Produces(MediaType.APPLICATION_JSON) @ApiOperation(value = "根据区块hash查询区块头", notes = "result.data: blockHeaderJson 返回对应的区块头信息") @ApiResponses(value = { @ApiResponse(code = 200, message = "success", response = BlockDto.class) }) RpcClientResult getHeaderHash(@ApiParam(name = "hash", value = "区块hash", required = true)
                                         @PathParam("hash") String hash); @GET @Path("/hash/{hash}") @Produces(MediaType.APPLICATION_JSON) @ApiOperation("根据区块hash查询区块，包含区块打包的所有交易信息，此接口返回数据量较多，谨慎调用") @ApiResponses(value = { @ApiResponse(code = 200, message = "success", response = BlockDto.class) }) RpcClientResult loadBlock(@ApiParam(name = "hash", value = "区块hash", required = true)
                                     @PathParam("hash") String hash); @GET @Path("/height/{height}") @Produces(MediaType.APPLICATION_JSON) @ApiOperation("根据区块高度查询区块，包含区块打包的所有交易信息，此接口返回数据量较多，谨慎调用") @ApiResponses(value = { @ApiResponse(code = 200, message = "success", response = BlockDto.class) }) RpcClientResult getBlock(@ApiParam(name = "height", value = "区块高度", required = true)
                                    @PathParam("height") Long height); @GET @Path("/newest") @Produces(MediaType.APPLICATION_JSON) @ApiOperation(value = "查询最新区块头信息", notes = "result.data: blockHeaderJson 返回对应的区块头信息") @ApiResponses(value = { @ApiResponse(code = 200, message = "success", response = BlockDto.class) }) RpcClientResult getBestBlockHeader(); @GET @Path("/newest/height") @Produces(MediaType.APPLICATION_JSON) @ApiOperation(value = "查询最新区块高度") @ApiResponses(value = { @ApiResponse(code = 200, message = "success", response = RpcClientResult.class) }) RpcClientResult getBestBlockHight(); @GET @Path("/newest/hash") @Produces(MediaType.APPLICATION_JSON) @ApiOperation(value = "查询最新区块的hash") @ApiResponses(value = { @ApiResponse(code = 200, message = "success", response = RpcClientResult.class) }) RpcClientResult getBestBlockHash(); @GET @Path("/bytes") @Produces(MediaType.APPLICATION_JSON) RpcClientResult getBlockBytes(@QueryParam("hash") String hash); @GET @Path("/bytes/height") @Produces(MediaType.APPLICATION_JSON) RpcClientResult getBlockBytes(@QueryParam("height") long height); @GET @Produces(MediaType.APPLICATION_JSON) @ApiOperation("根据区块高度查询区块列表，包含区块打包的所有交易信息，此接口返回数据量较多，谨慎调用") @ApiResponses(value = { @ApiResponse(code = 200, message = "success", response = BlockDto.class) }) RpcClientResult getBlockList(@QueryParam("startHeight") Long startHeight, @QueryParam("size") Long size); @GET() @Path("/info") @Produces(MediaType.APPLICATION_JSON) @ApiOperation("查询最近五块区块的基本信息（用于开发调试）") @ApiResponses(value = { @ApiResponse(code = 200, message = "success", response = BlockInfoDto.class) }) RpcClientResult getBlockInfoList(); }
BlockResource { @GET @Path("/bytes") @Produces(MediaType.APPLICATION_JSON) public RpcClientResult getBlockBytes(@QueryParam("hash") String hash) throws IOException { Result result; if (!NulsDigestData.validHash(hash)) { return Result.getFailed(KernelErrorCode.PARAMETER_ERROR).toRpcClientResult(); } Block block = null; try { block = blockService.getBlock(NulsDigestData.fromDigestHex(hash), true).getData(); } catch (NulsException e) { Log.error(e); } if (block == null) { result = Result.getFailed(ProtocolErroeCode.BLOCK_IS_NULL); } else { result = Result.getSuccess(); Map<String, String> map = new HashMap<>(); map.put("value", Base64.getEncoder().encodeToString(block.serialize())); result.setData(map); } return result.toRpcClientResult(); }  @GET @Path("/header/height/{height}") @Produces(MediaType.APPLICATION_JSON) @ApiOperation(value = "根据区块高度查询区块头", notes = "result.data: blockHeaderJson 返回对应的区块头信息") @ApiResponses(value = { @ApiResponse(code = 200, message = "success", response = BlockDto.class) }) RpcClientResult getHeaderByHeight(@ApiParam(name = "height", value = "区块高度", required = true)
                                             @PathParam("height") Integer height); @GET @Path("/header/txHash/height/{height}") @Produces(MediaType.APPLICATION_JSON) @ApiOperation(value = "根据区块高度查询区块头", notes = "result.data: blockHeaderJson 返回对应的区块头信息") @ApiResponses(value = { @ApiResponse(code = 200, message = "success", response = BlockDto.class) }) RpcClientResult getHeaderHashesByHeight(@ApiParam(name = "height", value = "区块高度", required = true)
                                                   @PathParam("height") Integer height); @GET @Path("/header/hash/{hash}") @Produces(MediaType.APPLICATION_JSON) @ApiOperation(value = "根据区块hash查询区块头", notes = "result.data: blockHeaderJson 返回对应的区块头信息") @ApiResponses(value = { @ApiResponse(code = 200, message = "success", response = BlockDto.class) }) RpcClientResult getHeader(@ApiParam(name = "hash", value = "区块hash", required = true)
                                     @PathParam("hash") String hash); @GET @Path("/header/txHash/hash/{hash}") @Produces(MediaType.APPLICATION_JSON) @ApiOperation(value = "根据区块hash查询区块头", notes = "result.data: blockHeaderJson 返回对应的区块头信息") @ApiResponses(value = { @ApiResponse(code = 200, message = "success", response = BlockDto.class) }) RpcClientResult getHeaderHash(@ApiParam(name = "hash", value = "区块hash", required = true)
                                         @PathParam("hash") String hash); @GET @Path("/hash/{hash}") @Produces(MediaType.APPLICATION_JSON) @ApiOperation("根据区块hash查询区块，包含区块打包的所有交易信息，此接口返回数据量较多，谨慎调用") @ApiResponses(value = { @ApiResponse(code = 200, message = "success", response = BlockDto.class) }) RpcClientResult loadBlock(@ApiParam(name = "hash", value = "区块hash", required = true)
                                     @PathParam("hash") String hash); @GET @Path("/height/{height}") @Produces(MediaType.APPLICATION_JSON) @ApiOperation("根据区块高度查询区块，包含区块打包的所有交易信息，此接口返回数据量较多，谨慎调用") @ApiResponses(value = { @ApiResponse(code = 200, message = "success", response = BlockDto.class) }) RpcClientResult getBlock(@ApiParam(name = "height", value = "区块高度", required = true)
                                    @PathParam("height") Long height); @GET @Path("/newest") @Produces(MediaType.APPLICATION_JSON) @ApiOperation(value = "查询最新区块头信息", notes = "result.data: blockHeaderJson 返回对应的区块头信息") @ApiResponses(value = { @ApiResponse(code = 200, message = "success", response = BlockDto.class) }) RpcClientResult getBestBlockHeader(); @GET @Path("/newest/height") @Produces(MediaType.APPLICATION_JSON) @ApiOperation(value = "查询最新区块高度") @ApiResponses(value = { @ApiResponse(code = 200, message = "success", response = RpcClientResult.class) }) RpcClientResult getBestBlockHight(); @GET @Path("/newest/hash") @Produces(MediaType.APPLICATION_JSON) @ApiOperation(value = "查询最新区块的hash") @ApiResponses(value = { @ApiResponse(code = 200, message = "success", response = RpcClientResult.class) }) RpcClientResult getBestBlockHash(); @GET @Path("/bytes") @Produces(MediaType.APPLICATION_JSON) RpcClientResult getBlockBytes(@QueryParam("hash") String hash); @GET @Path("/bytes/height") @Produces(MediaType.APPLICATION_JSON) RpcClientResult getBlockBytes(@QueryParam("height") long height); @GET @Produces(MediaType.APPLICATION_JSON) @ApiOperation("根据区块高度查询区块列表，包含区块打包的所有交易信息，此接口返回数据量较多，谨慎调用") @ApiResponses(value = { @ApiResponse(code = 200, message = "success", response = BlockDto.class) }) RpcClientResult getBlockList(@QueryParam("startHeight") Long startHeight, @QueryParam("size") Long size); @GET() @Path("/info") @Produces(MediaType.APPLICATION_JSON) @ApiOperation("查询最近五块区块的基本信息（用于开发调试）") @ApiResponses(value = { @ApiResponse(code = 200, message = "success", response = BlockInfoDto.class) }) RpcClientResult getBlockInfoList();  }