Rev470, Keep track downloaded optional files in hashfield, Peer getHashfield command, Check optional files on verifyFiles, Test hashfield, Test hashfield exchange

This commit is contained in:
HelloZeroNet 2015-10-11 02:22:53 +02:00
parent f8fd58866b
commit 9400e9f58f
10 changed files with 178 additions and 18 deletions

View file

@ -65,6 +65,8 @@ class FileRequest(object):
self.actionPex(params)
elif cmd == "listModified":
self.actionListModified(params)
elif cmd == "getHashfield":
self.actionGetHashfield(params)
elif cmd == "ping":
self.actionPing()
else:
@ -257,6 +259,20 @@ class FileRequest(object):
self.response({"modified_files": modified_files})
def actionGetHashfield(self, params):
site = self.sites.get(params["site"])
if not site or not site.settings["serving"]: # Site unknown or not serving
self.response({"error": "Unknown site"})
return False
# Add peer to site if not added before
connected_peer = site.addPeer(self.connection.ip, self.connection.port)
if connected_peer: # Just added
connected_peer.connect(self.connection) # Assign current connection to peer
self.response({"hashfield_raw": site.content_manager.hashfield.tostring()})
# Send a simple Pong! answer
def actionPing(self):
self.response("Pong!")