diff --git a/plugins/AnnounceZero/AnnounceZeroPlugin.py b/plugins/AnnounceZero/AnnounceZeroPlugin.py index de80aae5..14dba61e 100644 --- a/plugins/AnnounceZero/AnnounceZeroPlugin.py +++ b/plugins/AnnounceZero/AnnounceZeroPlugin.py @@ -46,7 +46,7 @@ class SitePlugin(object): s = time.time() need_types = ["ip4"] - if self.connection_server and self.connection_server.tor_manager.enabled: + if self.connection_server and self.connection_server.tor_manager and self.connection_server.tor_manager.enabled: need_types.append("onion") if mode == "start" or mode == "more": # Single: Announce only this site diff --git a/plugins/disabled-Bootstrapper/BootstrapperDb.py b/plugins/disabled-Bootstrapper/BootstrapperDb.py index b07ac471..44cf58c9 100644 --- a/plugins/disabled-Bootstrapper/BootstrapperDb.py +++ b/plugins/disabled-Bootstrapper/BootstrapperDb.py @@ -140,6 +140,7 @@ class BootstrapperDb(Db): FROM peer_to_hash LEFT JOIN peer USING (peer_id) WHERE %s + ORDER BY date_announced DESC LIMIT :limit """ % where res = self.execute(query, {"hashid": hashid, "ip4": ip4, "onions": onions, "port": port, "limit": limit}) diff --git a/src/Config.py b/src/Config.py index b31f1b0b..553c689d 100644 --- a/src/Config.py +++ b/src/Config.py @@ -8,7 +8,7 @@ class Config(object): def __init__(self, argv): self.version = "0.3.6" - self.rev = 932 + self.rev = 936 self.argv = argv self.action = None self.config_file = "zeronet.conf" diff --git a/src/Site/Site.py b/src/Site/Site.py index 64dbda21..6c2813e1 100644 --- a/src/Site/Site.py +++ b/src/Site/Site.py @@ -404,7 +404,7 @@ class Site(object): inner_path, len(published), len(passive_peers) )) - for peer in passive_peers: + for peer in passive_peers[0:3]: gevent.spawn(self.publisher, inner_path, passive_peers, published, limit=limit+3) # Send my hashfield to every connected peer if changed diff --git a/src/Site/SiteStorage.py b/src/Site/SiteStorage.py index 00a0bb1e..11d0dc40 100644 --- a/src/Site/SiteStorage.py +++ b/src/Site/SiteStorage.py @@ -384,4 +384,4 @@ class SiteStorage: return False # Some files not deleted else: self.log.debug("Site data directory deleted: %s..." % self.directory) - return True # All clean + return True # All clean \ No newline at end of file diff --git a/src/Worker/WorkerManager.py b/src/Worker/WorkerManager.py index 9819ad64..649794c0 100644 --- a/src/Worker/WorkerManager.py +++ b/src/Worker/WorkerManager.py @@ -273,9 +273,29 @@ class WorkerManager: found_peers = set([peer for hash_id_peers in found.values() for peer in hash_id_peers]) self.startWorkers(found_peers) + if len(found) < len(optional_hash_ids): + self.log.debug("No findHash result, try random peers: %s" % (optional_hash_ids - set(found))) + # Try to query random peers + threads = [] + peers = self.site.getConnectablePeers() + + for peer in peers[0:5]: + threads.append(gevent.spawn(peer.findHashIds, list(optional_hash_ids))) + + gevent.joinall(threads, timeout=15) + + found_ips = helper.mergeDicts([thread.value for thread in threads if thread.value]) + found = self.addOptionalPeers(found_ips) + self.log.debug("Found optional files after findhash random peers: %s/%s" % (len(found), len(optional_hash_ids))) + + if found: + found_peers = set([peer for hash_id_peers in found.values() for peer in hash_id_peers]) + self.startWorkers(found_peers) + if len(found) < len(optional_hash_ids): self.log.debug("No findhash result for optional files: %s" % (optional_hash_ids - set(found))) + # Stop all worker def stopWorkers(self): for worker in self.workers.values():