use of com.jd.blockchain.ledger.MerkleNode in project jdchain-core by blockchain-jd-com.
the class MerkleSequenceTree method getMaxDataNode.
private DataNode getMaxDataNode() {
MerkleNode node = root;
PathNode pathNode;
int idx = -1;
while (node.getLevel() > 0) {
pathNode = (PathNode) node;
// find the last child, because all children are ascension sorted by sn;
for (idx = pathNode.childrenHashes.length - 1; idx > -1; idx--) {
if (pathNode.childrenHashes[idx] != null) {
break;
}
}
if (idx == -1) {
// no child;
return null;
}
// if child node have been loaded, then load it;
if (pathNode.children[idx] == null) {
if (pathNode.getLevel() > 1) {
// load path node;
PathNode child = loadPathNode(pathNode.childrenHashes[idx], setting.getAutoVerifyHash());
pathNode.attachChildNode(child, idx);
} else {
DataNode child = loadDataNode(pathNode.childrenHashes[idx], setting.getAutoVerifyHash());
pathNode.attachChildNode(child, idx);
}
}
node = pathNode.children[idx];
}
return (DataNode) node;
}
Aggregations