diff --git a/src/hashtree.py b/src/hashtree.py --- a/src/hashtree.py +++ b/src/hashtree.py @@ -1,5 +1,6 @@ import hashlib import os +from datetime import datetime from util import progress @@ -22,13 +23,14 @@ class HashTree: size=stat.st_size # !! symlinks leafCount=(size-1)//HashTree.BLOCK_SIZE+1 # number of leaf blocks res=cls(leafCount) - print("hashing file:") + print(datetime.now(), "hashing file:") for i in range(leafCount): data=f.read(HashTree.BLOCK_SIZE) res.insertLeaf(hashlib.sha256(data).digest()[HashTree.HASH_LEN:]) progress(i, leafCount) + print("100%") res.buildTree() return res @@ -73,10 +75,11 @@ class HashTree: ## Fast construction of the tree over the leaves. O(n). def buildTree(self): - print("building tree:") + print(datetime.now(), "building tree:") for i in range(self.leafStart-1,-1,-1): self.store[i]=hashlib.sha256(self.store[i*2+1]+self.store[i*2+2]).digest()[HashTree.HASH_LEN:] progress(i, -1, self.leafStart - 1) + print() if __name__=="__main__":