Search in sources :

Example 1 with BlockType

use of io.nem.symbol.sdk.model.blockchain.BlockType in project nem2-sdk-java by nemtech.

the class BlockRepositoryOkHttpImpl method toBlockInfo.

public static BlockInfo toBlockInfo(BlockInfoDTO blockInfoDTO, JsonHelper jsonHelper) {
    ImportanceBlockDTO block = jsonHelper.convert(blockInfoDTO.getBlock(), ImportanceBlockDTO.class);
    NetworkType networkType = NetworkType.rawValueOf(block.getNetwork().getValue());
    BlockType type = BlockType.rawValueOf(block.getType());
    // Remove before public net release
    if (type == BlockType.NORMAL_BLOCK || block.getVotingEligibleAccountsCount() == null)
        return new BlockInfo(blockInfoDTO.getId(), block.getSize(), blockInfoDTO.getMeta().getHash(), blockInfoDTO.getMeta().getGenerationHash(), blockInfoDTO.getMeta().getTotalFee(), blockInfoDTO.getMeta().getStateHashSubCacheMerkleRoots(), blockInfoDTO.getMeta().getTransactionsCount(), blockInfoDTO.getMeta().getTotalTransactionsCount(), blockInfoDTO.getMeta().getStatementsCount(), blockInfoDTO.getMeta().getStateHashSubCacheMerkleRoots(), block.getSignature(), PublicAccount.createFromPublicKey(block.getSignerPublicKey(), networkType), networkType, block.getVersion(), type, block.getHeight(), block.getTimestamp(), block.getDifficulty(), block.getFeeMultiplier(), block.getPreviousBlockHash(), block.getTransactionsHash(), block.getReceiptsHash(), block.getStateHash(), block.getProofGamma(), block.getProofScalar(), block.getProofVerificationHash(), MapperUtils.toAddress(block.getBeneficiaryAddress()));
    else {
        return new ImportanceBlockInfo(blockInfoDTO.getId(), block.getSize(), blockInfoDTO.getMeta().getHash(), blockInfoDTO.getMeta().getGenerationHash(), blockInfoDTO.getMeta().getTotalFee(), blockInfoDTO.getMeta().getStateHashSubCacheMerkleRoots(), blockInfoDTO.getMeta().getTransactionsCount(), blockInfoDTO.getMeta().getTotalTransactionsCount(), blockInfoDTO.getMeta().getStatementsCount(), blockInfoDTO.getMeta().getStateHashSubCacheMerkleRoots(), block.getSignature(), PublicAccount.createFromPublicKey(block.getSignerPublicKey(), networkType), networkType, block.getVersion(), type, block.getHeight(), block.getTimestamp(), block.getDifficulty(), block.getFeeMultiplier(), block.getPreviousBlockHash(), block.getTransactionsHash(), block.getReceiptsHash(), block.getStateHash(), block.getProofGamma(), block.getProofScalar(), block.getProofVerificationHash(), MapperUtils.toAddress(block.getBeneficiaryAddress()), block.getVotingEligibleAccountsCount(), block.getHarvestingEligibleAccountsCount(), block.getTotalVotingBalance(), block.getPreviousImportanceBlockHash());
    }
}
Also used : BlockType(io.nem.symbol.sdk.model.blockchain.BlockType) NetworkType(io.nem.symbol.sdk.model.network.NetworkType) BlockInfo(io.nem.symbol.sdk.model.blockchain.BlockInfo) ImportanceBlockInfo(io.nem.symbol.sdk.model.blockchain.ImportanceBlockInfo) ImportanceBlockDTO(io.nem.symbol.sdk.openapi.okhttp_gson.model.ImportanceBlockDTO) ImportanceBlockInfo(io.nem.symbol.sdk.model.blockchain.ImportanceBlockInfo)

Example 2 with BlockType

use of io.nem.symbol.sdk.model.blockchain.BlockType in project nem2-sdk-java by nemtech.

the class BlockRepositoryVertxImpl method toBlockInfo.

public static BlockInfo toBlockInfo(BlockInfoDTO blockInfoDTO, JsonHelper jsonHelper) {
    ImportanceBlockDTO block = jsonHelper.convert(blockInfoDTO.getBlock(), ImportanceBlockDTO.class);
    NetworkType networkType = NetworkType.rawValueOf(block.getNetwork().getValue());
    BlockType type = BlockType.rawValueOf(block.getType());
    // Remove before public net release
    if (type == BlockType.NORMAL_BLOCK || block.getVotingEligibleAccountsCount() == null)
        return new BlockInfo(blockInfoDTO.getId(), block.getSize(), blockInfoDTO.getMeta().getHash(), blockInfoDTO.getMeta().getGenerationHash(), blockInfoDTO.getMeta().getTotalFee(), blockInfoDTO.getMeta().getStateHashSubCacheMerkleRoots(), blockInfoDTO.getMeta().getTransactionsCount(), blockInfoDTO.getMeta().getTotalTransactionsCount(), blockInfoDTO.getMeta().getStatementsCount(), blockInfoDTO.getMeta().getStateHashSubCacheMerkleRoots(), block.getSignature(), PublicAccount.createFromPublicKey(block.getSignerPublicKey(), networkType), networkType, block.getVersion(), type, block.getHeight(), block.getTimestamp(), block.getDifficulty(), block.getFeeMultiplier(), block.getPreviousBlockHash(), block.getTransactionsHash(), block.getReceiptsHash(), block.getStateHash(), block.getProofGamma(), block.getProofScalar(), block.getProofVerificationHash(), MapperUtils.toAddress(block.getBeneficiaryAddress()));
    else {
        return new ImportanceBlockInfo(blockInfoDTO.getId(), block.getSize(), blockInfoDTO.getMeta().getHash(), blockInfoDTO.getMeta().getGenerationHash(), blockInfoDTO.getMeta().getTotalFee(), blockInfoDTO.getMeta().getStateHashSubCacheMerkleRoots(), blockInfoDTO.getMeta().getTransactionsCount(), blockInfoDTO.getMeta().getTotalTransactionsCount(), blockInfoDTO.getMeta().getStatementsCount(), blockInfoDTO.getMeta().getStateHashSubCacheMerkleRoots(), block.getSignature(), PublicAccount.createFromPublicKey(block.getSignerPublicKey(), networkType), networkType, block.getVersion(), type, block.getHeight(), block.getTimestamp(), block.getDifficulty(), block.getFeeMultiplier(), block.getPreviousBlockHash(), block.getTransactionsHash(), block.getReceiptsHash(), block.getStateHash(), block.getProofGamma(), block.getProofScalar(), block.getProofVerificationHash(), MapperUtils.toAddress(block.getBeneficiaryAddress()), block.getVotingEligibleAccountsCount(), block.getHarvestingEligibleAccountsCount(), block.getTotalVotingBalance(), block.getPreviousImportanceBlockHash());
    }
}
Also used : BlockType(io.nem.symbol.sdk.model.blockchain.BlockType) NetworkType(io.nem.symbol.sdk.model.network.NetworkType) BlockInfo(io.nem.symbol.sdk.model.blockchain.BlockInfo) ImportanceBlockInfo(io.nem.symbol.sdk.model.blockchain.ImportanceBlockInfo) ImportanceBlockDTO(io.nem.symbol.sdk.openapi.vertx.model.ImportanceBlockDTO) ImportanceBlockInfo(io.nem.symbol.sdk.model.blockchain.ImportanceBlockInfo)

Aggregations

BlockInfo (io.nem.symbol.sdk.model.blockchain.BlockInfo)2 BlockType (io.nem.symbol.sdk.model.blockchain.BlockType)2 ImportanceBlockInfo (io.nem.symbol.sdk.model.blockchain.ImportanceBlockInfo)2 NetworkType (io.nem.symbol.sdk.model.network.NetworkType)2 ImportanceBlockDTO (io.nem.symbol.sdk.openapi.okhttp_gson.model.ImportanceBlockDTO)1 ImportanceBlockDTO (io.nem.symbol.sdk.openapi.vertx.model.ImportanceBlockDTO)1