@@ -27,25 +27,26 @@ outcoming=networkWriter.input
# determine which blocks to send
while len(nodeStack)>0:
i=nodeStack.pop()
jsonData={"command":"req", "index":i}
outcoming.put((jsonData,b""))
jsonData,binData=incoming.get(timeout=2)
assert jsonData["index"]==i
assert jsonData["dataType"]=="hash"
if localTree.store[i]!=binData:
if 2*i+3<len(localTree.store): # inner node
# ie. 0-6 nodes, 7-14 leaves. 2*6+2<15
if 2*i+2<len(localTree.store): # inner node
nodeStack.append(2*i+2)
nodeStack.append(2*i+1)
else: blocksToTransfer.append(i-localTree.leafStart) # leaf
# send the actual data
print(blocksToTransfer)
dataFile=open("clientFile.txt",mode="rb")
for i in blocksToTransfer:
jsonData={"command":"send", "index":i, "dataType":"data"}
dataFile.seek(i*localTree.BLOCK_SIZE)
Status change: