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

Method addOptionalPeers

src/Worker/WorkerManager.py:256–273  ·  view source on GitHub ↗
(self, found_ips)

Source from the content-addressed store, hash-verified

254
255 # Add peers to tasks from found result
256 def addOptionalPeers(self, found_ips):
257 found = collections.defaultdict(list)
258 for hash_id, peer_ips in found_ips.items():
259 task = [task for task in self.tasks if task["optional_hash_id"] == hash_id]
260 if task: # Found task, lets take the first
261 task = task[0]
262 else:
263 continue
264 for peer_ip in peer_ips:
265 peer = self.site.addPeer(peer_ip[0], peer_ip[1], return_peer=True, source="optional")
266 if not peer:
267 continue
268 if self.taskAddPeer(task, peer):
269 found[hash_id].append(peer)
270 if peer.hashfield.appendHashId(hash_id): # Peer has this file
271 peer.time_hashfield = None # Peer hashfield probably outdated
272
273 return found
274
275 # Start find peers for optional files
276 @util.Noparallel(blocking=False, ignore_args=True)

Callers 1

startFindOptionalMethod · 0.95

Calls 4

taskAddPeerMethod · 0.95
itemsMethod · 0.80
addPeerMethod · 0.80
appendHashIdMethod · 0.80

Tested by

no test coverage detected