MCPcopy Index your code
hub / github.com/HelloZeroNet/ZeroNet / actionGetHashfield

Method actionGetHashfield

src/File/FileRequest.py:357–371  ·  view source on GitHub ↗
(self, params)

Source from the content-addressed store, hash-verified

355 self.response({"modified_files": modified_files})
356
357 def actionGetHashfield(self, params):
358 site = self.sites.get(params["site"])
359 if not site or not site.isServing(): # Site unknown or not serving
360 self.response({"error": "Unknown site"})
361 self.connection.badAction(5)
362 return False
363
364 # Add peer to site if not added before
365 peer = site.addPeer(self.connection.ip, self.connection.port, return_peer=True, source="request")
366 if not peer.connection: # Just added
367 peer.connect(self.connection) # Assign current connection to peer
368
369 peer.time_my_hashfield_sent = time.time() # Don't send again if not changed
370
371 self.response({"hashfield_raw": site.content_manager.hashfield.tobytes()})
372
373 def findHashIds(self, site, hash_ids, limit=100):
374 back = collections.defaultdict(lambda: collections.defaultdict(list))

Callers

nothing calls this directly

Calls 7

responseMethod · 0.95
isServingMethod · 0.80
badActionMethod · 0.80
addPeerMethod · 0.80
getMethod · 0.45
connectMethod · 0.45
tobytesMethod · 0.45

Tested by

no test coverage detected