Always publish to 5 peers and remove discrimination of active peers
This commit is contained in:
parent
16d01c961e
commit
6f4b896bce
1 changed files with 6 additions and 15 deletions
|
@ -361,10 +361,6 @@ class Site(object):
|
||||||
|
|
||||||
threads = 5
|
threads = 5
|
||||||
if limit == "default":
|
if limit == "default":
|
||||||
if len(self.peers) > 50:
|
|
||||||
limit = 3
|
|
||||||
threads = 3
|
|
||||||
else:
|
|
||||||
limit = 5
|
limit = 5
|
||||||
|
|
||||||
peers = self.getConnectedPeers()
|
peers = self.getConnectedPeers()
|
||||||
|
@ -395,19 +391,14 @@ class Site(object):
|
||||||
if len(published) == 0:
|
if len(published) == 0:
|
||||||
gevent.joinall(publishers) # No successful publish, wait for all publisher
|
gevent.joinall(publishers) # No successful publish, wait for all publisher
|
||||||
|
|
||||||
# Make sure the connected passive peers got the update
|
# Publish more peers in the backgroup
|
||||||
passive_peers = [
|
|
||||||
peer for peer in peers
|
|
||||||
if peer.connection and not peer.connection.closed and peer.key.endswith(":0") and peer not in published
|
|
||||||
] # Every connected passive peer that we not published to
|
|
||||||
|
|
||||||
self.log.info(
|
self.log.info(
|
||||||
"Successfuly %s published to %s peers, publishing to %s more passive peers" % (
|
"Successfuly %s published to %s peers, publishing to %s more peers in the background" % (
|
||||||
inner_path, len(published), len(passive_peers)
|
inner_path, len(published), limit
|
||||||
))
|
))
|
||||||
|
|
||||||
for peer in passive_peers[0:limit]:
|
for thread in range(2):
|
||||||
gevent.spawn(self.publisher, inner_path, passive_peers, published, limit=limit*2)
|
gevent.spawn(self.publisher, inner_path, peers, published, limit=limit*2)
|
||||||
|
|
||||||
# Send my hashfield to every connected peer if changed
|
# Send my hashfield to every connected peer if changed
|
||||||
gevent.spawn(self.sendMyHashfield, 100)
|
gevent.spawn(self.sendMyHashfield, 100)
|
||||||
|
|
Loading…
Reference in a new issue