本文整理了Java中io.nuls.kernel.model.Block.serialize()
方法的一些代码示例,展示了Block.serialize()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Block.serialize()
方法的具体详情如下:
包路径:io.nuls.kernel.model.Block
类名称:Block
方法名:serialize
暂无
代码示例来源:origin: nuls-io/nuls
@GET
@Path("/bytes/height")
@Produces(MediaType.APPLICATION_JSON)
public RpcClientResult getBlockBytes(@QueryParam("height") long height) throws IOException {
Result result;
if (height < 0) {
return Result.getFailed(KernelErrorCode.PARAMETER_ERROR).toRpcClientResult();
}
Block block = null;
try {
// 包含智能合约内部转账(从合约转出)交易的区块
block = blockService.getBlock(height, true).getData();
} catch (Exception 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();
}
代码示例来源:origin: nuls-io/nuls
@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();
}
代码示例来源:origin: nuls-io/nuls
@Override
public boolean save(Block block) {
assert (block != null);
Result result = null;
try {
result = dbService.put(DB_NAME, block.getHeader().getHash().getDigestBytes(), block.serialize());
} catch (IOException e) {
Log.error(e);
return false;
}
return result.isSuccess();
}
内容来源于网络,如有侵权,请联系作者删除!