Skip to content

Instantly share code, notes, and snippets.

@aenhsaihan
aenhsaihan / merkletree-solution.py
Created June 10, 2020 03:19 — forked from georgeRenard/merkletree-solution.py
Merkle Tree Implementation Solution
def build_root(self, iterable):
collection = list(iterable)
assert(len(collection) != 0)
if len(collection) % 2 != 0:
collection.append(collection[-1])
collection = [self.__Node(self.digest(x)) for x in collection]
return self.__build_root(collection)
def __build_root(self, collection):
size = len(collection)