Skip to content

Commit a5ccab4

Browse files
committed
#75 Update node branch split check in smt-s
1 parent 4c3ad04 commit a5ccab4

2 files changed

Lines changed: 2 additions & 2 deletions

File tree

src/main/java/org/unicitylabs/sdk/smt/radix/SparseMerkleTree.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ private static Branch buildTree(Branch branch, BigInteger keyPath, byte[] key, b
105105
NodeBranch nodeBranch = (NodeBranch) branch;
106106

107107
// if node branch is split in the middle
108-
if (commonPath.getPath().compareTo(branch.getPath()) < 0) {
108+
if (!commonPath.getPath().equals(branch.getPath())) {
109109
LeafBranch newBranch = new PendingLeafBranch(keyPath, key, value);
110110
return new PendingNodeBranch(commonPath.getPath(), commonPath.getLength(),
111111
isRight ? branch : newBranch, isRight ? newBranch : branch);

src/main/java/org/unicitylabs/sdk/smt/radixsum/SparseMerkleSumTree.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ private static Branch buildTree(Branch branch, BigInteger keyPath, byte[] key, b
114114
NodeBranch nodeBranch = (NodeBranch) branch;
115115

116116
// if node branch is split in the middle
117-
if (commonPath.getPath().compareTo(branch.getPath()) < 0) {
117+
if (!commonPath.getPath().equals(branch.getPath())) {
118118
LeafBranch newBranch = new PendingLeafBranch(keyPath, key, data, value);
119119
return new PendingNodeBranch(commonPath.getPath(), commonPath.getLength(),
120120
isRight ? branch : newBranch, isRight ? newBranch : branch);

0 commit comments

Comments
 (0)