(self, found_ips)
| 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) |
no test coverage detected