Changeset - 7d21dd70864a
[Not reviewed]
default
0 3 0
Laman - 7 years ago 2017-10-19 12:34:57

minor enhancements
3 files changed with 6 insertions and 4 deletions:
0 comments (0 inline, 0 general)
src/client.py
Show inline comments
 
@@ -65,7 +65,7 @@ class Client:
 
		progress=Progress(localTree.leafCount)
 
		while len(nodeStack)>0:
 
			indices=[]
 
			for i in range(256):
 
			for i in range(conf.batchSize):
 
				indices.append(nodeStack.pop())
 
				if len(nodeStack)==0: break
 
			self._outcoming.writeMsg({"command":"req", "index":indices, "dataType":"hash"})
src/config.py
Show inline comments
 
@@ -20,3 +20,5 @@ directory=os.path.join(os.path.dirname(_
 
certfile=os.path.join(directory,"certs/cert.pem")
 
keyfile=os.path.join(directory,"certs/key.pem")
 
peers=os.path.join(directory,"certs/peers.pem")
 

	
 
batchSize=256
src/hashtree.py
Show inline comments
 
@@ -28,7 +28,7 @@ class HashTree:
 
			progress=Progress(leafCount)
 
			for i in range(leafCount):
 
				data=f.read(HashTree.BLOCK_SIZE)
 
				res.insertLeaf(hashlib.sha256(data).digest()[HashTree.HASH_LEN:])
 
				res.insertLeaf(hashlib.sha256(data).digest()[-HashTree.HASH_LEN:])
 

	
 
				progress.p(i)
 
			progress.done()
 
@@ -70,7 +70,7 @@ class HashTree:
 
	## Updates the node at index and all its ancestors.
 
	def updateNode(self,index):
 
		while index>=0:
 
			self.store[index]=hashlib.sha256(self.store[index*2+1]+self.store[index*2+2]).digest()[HashTree.HASH_LEN:]
 
			self.store[index]=hashlib.sha256(self.store[index*2+1]+self.store[index*2+2]).digest()[-HashTree.HASH_LEN:]
 
			index=(index-1)//2
 
			
 
	## Fast construction of the tree over the leaves. O(n).
 
@@ -78,7 +78,7 @@ class HashTree:
 
		print(datetime.now(), "building tree:")
 
		progress=Progress(-1, self.leafStart-1)
 
		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:]
 
			self.store[i]=hashlib.sha256(self.store[i*2+1]+self.store[i*2+2]).digest()[-HashTree.HASH_LEN:]
 
			progress.p(i)
 
		progress.done()
 

	
0 comments (0 inline, 0 general)