Changeset - b0515ceb502d
[Not reviewed]
tip default
1 4 0
Laman - 5 years ago 2020-06-07 13:28:55

actually flushing the files
5 files changed with 9 insertions and 43 deletions:
0 comments (0 inline, 0 general)
src/client.py
Show inline comments
 
@@ -164,12 +164,13 @@ class Client(NetNode):
 
				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)
 

	
 
					t = datetime.now().timestamp()
 
					if t-last_flushed >= 60:
 
						data_file.flush()
 
						if self._tree_file:
 
							self._update_tree()
 
						self._refresh_lock()
 
						last_flushed = t
 

	
 
				stats.log_transferred_block()
src/config.py
Show inline comments
 
@@ -28,8 +28,8 @@ lowest_compatible = [0, 1, 0] # tuple is
 

	
 
hosts = conf.get("hosts", ["127.0.0.1"])
 
port = conf.get("port", 9901)
 

	
 
bSize = conf.get("batch_size", dict())
 
class batch_size:
 
	hash = bSize.get("hash", 256)
 
	hash = bSize.get("hash", 16384)
 
	data = bSize.get("data", 64)
src/datafile.py
Show inline comments
 
@@ -22,8 +22,11 @@ class DataFile:
 
	def read_from(self, i, byte_count=BLOCK_SIZE):
 
		if i!=self._last_index+1:
 
			self._f.seek(i*BLOCK_SIZE)
 
		self._last_index = i
 
		return self._f.read(byte_count)
 

	
 
	def flush(self):
 
		self._f.flush()
 

	
 
	def close(self):
 
		self._f.close()
src/morevna.sh
Show inline comments
 
deleted file
src/server.py
Show inline comments
 
@@ -91,13 +91,15 @@ class Server(NetNode):
 
				self._outcoming.write_msg({"command": "deny", "status": status.incompatible.parameters})
 
			if json_data["version"]<conf.lowest_compatible:
 
				self._outcoming.write_msg({"command": "deny", "status": status.incompatible.version})
 
			if json_data["action"]=="pull" and self.is_locked():
 
				self._outcoming.write_msg({"command": "deny", "status": status.locked})
 
			if json_data["action"]=="push" and not self.is_locked():
 
				self._lock()
 
				try: self._lock()
 
				except Exception:
 
					pass
 

	
 
			self._last_flushed = datetime.now().timestamp()
 
			self._outcoming.write_msg({"command": "init", "version": conf.version})
 

	
 
		elif json_data["command"]=="req":
 
			if json_data["dataType"]=="data":
 
@@ -148,12 +150,13 @@ class Server(NetNode):
 
			self._data_file.write_at(k, block)
 
			if self._tree_file:
 
				self._new_leaves[k+self._tree.leaf_start] = hash_block(block)
 

	
 
		t = datetime.now().timestamp()
 
		if t-self._last_flushed>=60:
 
			self._data_file.flush()
 
			if self._tree_file:
 
				self._update_tree()
 
			self._refresh_lock()
 
			self._last_flushed = t
 

	
 
		return ({"command": "ack", "index": indices},)
0 comments (0 inline, 0 general)