Skip to content

Commit

Permalink
Merge pull request #5 from kcalvinalvin/2024-08-20-simplify-add
Browse files Browse the repository at this point in the history
simplify addition
  • Loading branch information
kcalvinalvin authored Aug 21, 2024
2 parents 03f0774 + cace749 commit e63eb74
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions pytreexo.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,13 @@ def __eq__(self, other):

def add(self, adds: [bytes]):
for add in adds:
newroot = add
row = 0
while (self.numleaves >> row) & 1 == 1:
for row in range(tree_rows(self.numleaves)+1):
if (self.numleaves >> row) & 1 == 0:
break
root = self.roots.pop()
if root is None:
continue
else:
newroot = parent_hash(root, newroot)
row += 1
add = parent_hash(root, add)

self.roots.append(newroot)
self.roots.append(add)
self.numleaves += 1

def verify(self, dels: [bytes], proof: Proof) -> [int]:
Expand Down

0 comments on commit e63eb74

Please sign in to comment.