Rev936, Fix Bootstrapper test without tormanager, Bootstrapper return latest announced peers, Only create 3 threads for passive peers
This commit is contained in:
parent
6cbb6adcfc
commit
08005499fb
6 changed files with 25 additions and 4 deletions
|
@ -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
|
||||
|
|
|
@ -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})
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
|
@ -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():
|
||||
|
|
Loading…
Reference in a new issue