Search in sources :

Example 1 with MerkleTreeLeaf

use of io.nem.symbol.sdk.model.state.MerkleTreeLeaf 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);
}
Also used : MerkleTree(io.nem.symbol.sdk.model.state.MerkleTree) MerkleStateInfo(io.nem.symbol.sdk.model.blockchain.MerkleStateInfo) Objects(java.util.Objects) MerkleTreeLeaf(io.nem.symbol.sdk.model.state.MerkleTreeLeaf) MerkleTreeBranch(io.nem.symbol.sdk.model.state.MerkleTreeBranch)

Example 2 with MerkleTreeLeaf

use of io.nem.symbol.sdk.model.state.MerkleTreeLeaf 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);
}
Also used : MerkleTree(io.nem.symbol.sdk.model.state.MerkleTree) MerkleStateInfo(io.nem.symbol.sdk.model.blockchain.MerkleStateInfo) Objects(java.util.Objects) MerkleTreeLeaf(io.nem.symbol.sdk.model.state.MerkleTreeLeaf) MerkleTreeBranch(io.nem.symbol.sdk.model.state.MerkleTreeBranch)

Aggregations

MerkleStateInfo (io.nem.symbol.sdk.model.blockchain.MerkleStateInfo)2 MerkleTree (io.nem.symbol.sdk.model.state.MerkleTree)2 MerkleTreeBranch (io.nem.symbol.sdk.model.state.MerkleTreeBranch)2 MerkleTreeLeaf (io.nem.symbol.sdk.model.state.MerkleTreeLeaf)2 Objects (java.util.Objects)2