use of io.nuls.protocol.storage.po.BlockHeaderPo in project nuls by nuls-io.
the class BlockServiceImpl method getBlock.
/**
* 根据区块摘要获取区块(从存储中)
* Get the block (from storage) according to the block hash
*
* @param hash 区块摘要/block hash
* @return 区块/block
*/
@Override
public Result<Block> getBlock(NulsDigestData hash) {
BlockHeaderPo headerPo = blockHeaderStorageService.getBlockHeaderPo(hash);
if (null == headerPo) {
return Result.getFailed(ProtocolErroeCode.BLOCK_IS_NULL);
}
Block block = getBlock(headerPo);
return Result.getSuccess().setData(block);
}
use of io.nuls.protocol.storage.po.BlockHeaderPo in project nuls by nuls-io.
the class BlockServiceImpl method getBlock.
/**
* 根据区块高度获取区块(从存储中)
* Get the block (from storage) according to the block height
*
* @param height 区块高度/block height
* @param isNeedContractTransfer 是否需要把合约转账(从合约转出)交易添加到区块中/If necessary to add the contract transfer (from the contract) to the block
* @return 区块/block
*/
@Override
public Result<Block> getBlock(long height, boolean isNeedContractTransfer) {
BlockHeaderPo headerPo = blockHeaderStorageService.getBlockHeaderPo(height);
if (null == headerPo) {
return Result.getFailed(ProtocolErroeCode.BLOCK_IS_NULL);
}
Block block = getBlock(headerPo, isNeedContractTransfer);
return Result.getSuccess().setData(block);
}
use of io.nuls.protocol.storage.po.BlockHeaderPo in project nuls by nuls-io.
the class BlockServiceImpl method getBlock.
/**
* 根据区块高度获取区块(从存储中)
* Get the block (from storage) according to the block height
*
* @param height 区块高度/block height
* @return 区块/block
*/
@Override
public Result<Block> getBlock(long height) {
BlockHeaderPo headerPo = blockHeaderStorageService.getBlockHeaderPo(height);
if (null == headerPo) {
return Result.getFailed(ProtocolErroeCode.BLOCK_IS_NULL);
}
Block block = getBlock(headerPo);
return Result.getSuccess().setData(block);
}
use of io.nuls.protocol.storage.po.BlockHeaderPo in project nuls by nuls-io.
the class BlockServiceImpl method getBlockTxHash.
@Override
public List<String> getBlockTxHash(long height) {
BlockHeaderPo headerPo = blockHeaderStorageService.getBlockHeaderPo(height);
List<String> list = new ArrayList<>();
if (null != headerPo && null != headerPo.getTxHashList()) {
for (NulsDigestData hash : headerPo.getTxHashList()) {
list.add(hash.getDigestHex());
}
}
return list;
}
use of io.nuls.protocol.storage.po.BlockHeaderPo in project nuls by nuls-io.
the class PoConvertUtil method toBlockHeaderPo.
public static BlockHeaderPo toBlockHeaderPo(Block block) {
BlockHeaderPo po = new BlockHeaderPo();
po.setHash(block.getHeader().getHash());
po.setPreHash(block.getHeader().getPreHash());
po.setMerkleHash(block.getHeader().getMerkleHash());
po.setTime(block.getHeader().getTime());
po.setHeight(block.getHeader().getHeight());
po.setTxCount(block.getHeader().getTxCount());
po.setPackingAddress(block.getHeader().getPackingAddress());
po.setScriptSign(block.getHeader().getBlockSignature());
po.setExtend(block.getHeader().getExtend());
po.setTxHashList(block.getTxHashList());
po.setStateRoot(ContractUtil.getStateRoot(block.getHeader()));
return po;
}
Aggregations