Skip to content

Commit

Permalink
Remove unused stuff(method,throws,variables)
Browse files Browse the repository at this point in the history
  • Loading branch information
mksong76 committed Aug 8, 2023
1 parent 16eee50 commit dff8ede
Showing 1 changed file with 4 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,28 +53,11 @@ private static byte[] getHash(int height, int offset) {
return hashes[idx+offset];
}

private static byte[][] getProof(int depth, int index) {
var proofs = new ArrayList<byte[]>();
for (int i=0 ; i<depth ; i++, index/=2) {
if (index%2 == 0) {
proofs.add(getHash(i, index+1));
} else {
proofs.add(getHash(i, index-1));
}
}
var ret = new byte[proofs.size()][];
for (int i=0 ; i<ret.length ; i++) {
ret[i] = proofs.get(i);
}
return ret;
}

private static byte[][] getProofAt(int height, int index) {
if (height > HASH_COUNT || index <0 || index >= height ) {
throw new IllegalArgumentException("InvalidHeightOrIndex");
}
var proofs = new ArrayList<byte[]>();
int covered = 2;
for (int i=0 ; (index|1)+1<=height ; i++, height/=2, index/=2) {
if (index%2 == 0) {
proofs.add(getHash(i, index+1));
Expand All @@ -90,7 +73,7 @@ private static byte[][] getProofAt(int height, int index) {
}

@Test
public void testBasic() throws Exception {
public void testBasic() {
var mta = new MerkleTreeAccumulator();
for (int i=0 ; i<HASH_COUNT ; i++) {
mta.add(hashes[i]);
Expand All @@ -102,16 +85,16 @@ public void testBasic() throws Exception {
}

@Test
public void testForAllSize() throws Exception {
public void testForAllSize() {
var mta = new MerkleTreeAccumulator();
for (int i=0 ; i<HASH_COUNT ; i++) {
mta.add(hashes[i]);
for (int j=0 ; j<i+1 ; j++) {
var proof = getProofAt((int)mta.getHeight(), j);
try {
mta.verify(proof, hashes[j], j, mta.getHeight());
} catch (Exception ex) {
throw new Exception("Invalid("+j+"/"+(i+1)+")", ex);
} catch (MTAException ex) {
throw new MTAException("Invalid("+j+"/"+(i+1)+")", ex);
}
}
int k = i+1;
Expand Down

0 comments on commit dff8ede

Please sign in to comment.