use of io.nem.symbol.sdk.model.state.MerkleTreeBranch in project nem2-sdk-java by nemtech.
the class MerkleMapper method toMerkleStateInfo.
public MerkleStateInfo toMerkleStateInfo(MerkleStateInfoDTO dto) {
MerkleTreeLeaf leaf = dto.getTree().stream().map(this::toLeaf).filter(Objects::nonNull).findFirst().orElse(null);
List<MerkleTreeBranch> branches = dto.getTree().stream().map(this::toBranch).filter(Objects::nonNull).collect(Collectors.toList());
MerkleTree tree = new MerkleTree(branches, leaf);
return new MerkleStateInfo(dto.getRaw(), tree);
}
use of io.nem.symbol.sdk.model.state.MerkleTreeBranch in project nem2-sdk-java by nemtech.
the class MerkleMapper method toMerkleStateInfo.
public MerkleStateInfo toMerkleStateInfo(MerkleStateInfoDTO dto) {
MerkleTreeLeaf leaf = dto.getTree().stream().map(this::toLeaf).filter(Objects::nonNull).findFirst().orElse(null);
List<MerkleTreeBranch> branches = dto.getTree().stream().map(this::toBranch).filter(Objects::nonNull).collect(Collectors.toList());
MerkleTree tree = new MerkleTree(branches, leaf);
return new MerkleStateInfo(dto.getRaw(), tree);
}
use of io.nem.symbol.sdk.model.state.MerkleTreeBranch in project nem2-sdk-java by nemtech.
the class MerkleMapper method toMerkleTreeBranch.
private MerkleTreeBranch toMerkleTreeBranch(Object dto, MerkleTreeNodeType type) {
MerkleTreeBranchDTO branch = getJsonHelper().convert(dto, MerkleTreeBranchDTO.class);
List<MerkleTreeBranchLink> links = branch.getLinks().stream().map(link -> new MerkleTreeBranchLink(link.getBit(), link.getLink())).collect(Collectors.toList());
return new MerkleTreeBranch(type, branch.getPath(), branch.getEncodedPath(), branch.getLinkMask(), links, branch.getBranchHash());
}
Aggregations