diff --git a/src/client.py b/src/client.py --- a/src/client.py +++ b/src/client.py @@ -151,6 +151,7 @@ class Client(NetNode): print(datetime.now(), "receiving data:") progress = Progress(len(blocks_to_transfer)) + last_flushed = datetime.now().timestamp() for k in range(0, len(blocks_to_transfer), conf.batch_size.data): indices = blocks_to_transfer[k:k+conf.batch_size.data] self._outcoming.write_msg({"command": "req", "index": indices, "dataType": "data"}) @@ -160,10 +161,14 @@ class Client(NetNode): block = bin_data[j*HashTree.BLOCK_SIZE:(j+1)*HashTree.BLOCK_SIZE] data_file.write_at(i, block) + log.info("block #{0}: {1}...{2}".format(i, block[:5], block[-5:])) if self._tree_file: self._new_leaves[i+self._tree.leaf_start] = hash_block(block) - log.info("block #{0}: {1}...{2}".format(i, block[:5], block[-5:])) + t = datetime.now().timestamp() + if t-last_flushed >= 60 and self._tree_file: + self._update_tree() + last_flushed = t stats.log_transferred_block() progress.p(k+j)