Changeset - be1b73affd1c
[Not reviewed]
Merge default
0 1 0
Laman - 8 years ago 2017-05-08 00:12:45

merge
1 file changed with 1 insertions and 0 deletions:
0 comments (0 inline, 0 general)
src/hashtree.py
Show inline comments
 
@@ -29,24 +29,25 @@ class HashTree:
 
		return res
 

	
 
	@classmethod
 
	def load(cls,filename):
 
		with open(filename,"rb") as f:
 
			stat=os.fstat(f.fileno())
 
			size=stat.st_size
 
			nodeCount=size//HashTree.HASH_LEN
 
			res=cls((nodeCount+1)//2)
 

	
 
			for i in range(nodeCount):
 
				res.store[i]=f.read(HashTree.HASH_LEN)
 
		return res
 

	
 
	def save(self,filename):
 
		with open(filename,"wb") as f:
 
			for h in self.store:
 
				f.write(h)
 

	
 
		
 
	## Inserts a leaf at the first empty position.
 
	#	
 
	#	Useful and used only during the tree construction.
 
	def insertLeaf(self,h):
 
		self.store[self.index]=h
0 comments (0 inline, 0 general)