| 989 | |
| 990 | # Update hashfield |
| 991 | def updateHashfield(self, limit=5): |
| 992 | # Return if no optional files |
| 993 | if not self.content_manager.hashfield and not self.content_manager.has_optional_files: |
| 994 | return False |
| 995 | |
| 996 | s = time.time() |
| 997 | queried = 0 |
| 998 | connected_peers = self.getConnectedPeers() |
| 999 | for peer in connected_peers: |
| 1000 | if peer.time_hashfield: |
| 1001 | continue |
| 1002 | if peer.updateHashfield(): |
| 1003 | queried += 1 |
| 1004 | if queried >= limit: |
| 1005 | break |
| 1006 | if queried: |
| 1007 | self.log.debug("Queried hashfield from %s peers in %.3fs" % (queried, time.time() - s)) |
| 1008 | return queried |
| 1009 | |
| 1010 | # Returns if the optional file is need to be downloaded or not |
| 1011 | def isDownloadable(self, inner_path): |