diff --git a/config-example.json b/config-example.json --- a/config-example.json +++ b/config-example.json @@ -1,5 +1,8 @@ { "hosts": ["127.0.0.1"], "port": 9901, - "batchSize": 64 + "batchSize": { + "hash": 256, + "data": 64 + } } diff --git a/src/client.py b/src/client.py --- a/src/client.py +++ b/src/client.py @@ -74,7 +74,7 @@ class Client(NetNode): progress=Progress(localTree.leafCount) while len(nodeStack)>0: indices=[] - for i in range(conf.batchSize): + for i in range(conf.batchSize.hash): indices.append(nodeStack.pop()) if len(nodeStack)==0: break self._outcoming.writeMsg({"command":"req", "index":indices, "dataType":"hash"}) @@ -111,10 +111,10 @@ class Client(NetNode): print(datetime.now(), "sending data:") progress=Progress(len(blocksToTransfer)) - for k in range(0,len(blocksToTransfer),conf.batchSize): + for k in range(0,len(blocksToTransfer),conf.batchSize.data): indices=[] blocks=[] - for j in range(conf.batchSize): + for j in range(conf.batchSize.data): if k+j>=len(blocksToTransfer): break i2=blocksToTransfer[k+j] if i1+1!=i2: @@ -148,8 +148,8 @@ class Client(NetNode): print(datetime.now(), "receiving data:") progress=Progress(len(blocksToTransfer)) - for k in range(0,len(blocksToTransfer),conf.batchSize): - indices=blocksToTransfer[k:k+conf.batchSize] + for k in range(0,len(blocksToTransfer),conf.batchSize.data): + indices=blocksToTransfer[k:k+conf.batchSize.data] self._outcoming.writeMsg({"command":"req", "index":indices, "dataType":"data"}) jsonData,binData=self._incoming.readMsg() assert jsonData["command"]=="send" and jsonData["index"]==indices and jsonData["dataType"]=="data", jsonData diff --git a/src/config.py b/src/config.py --- a/src/config.py +++ b/src/config.py @@ -27,4 +27,7 @@ lowestCompatible=[0,1,0] # tuple is more hosts=conf.get("hosts",["127.0.0.1"]) port=conf.get("port",9901) -batchSize=conf.get("batchSize",64) +bSize=conf.get("batchSize",dict()) +class batchSize: + hash=bSize.get("hash",256) + data=bSize.get("data",64) diff --git a/src/tests/test_overall.py b/src/tests/test_overall.py --- a/src/tests/test_overall.py +++ b/src/tests/test_overall.py @@ -17,7 +17,8 @@ handler=FileHandler("/tmp/morevna.log") handler.setFormatter(config.formatter) config.logger.addHandler(handler) -config.batchSize=8 +config.batchSize.hash=8 +config.batchSize.data=8 dataDir=os.path.join(config.directory,"src/tests/data") filename=os.path.join(dataDir,"test.img")