site connection stats, msgpack unpacker stats, make sure we dont skip any namecoin blocks, no more sha1 hash to content.json, keep 5 open connection in passive mode, publish got content to 5 peers, upnp retry 3 times, keep connection loggers
This commit is contained in:
parent
2491814070
commit
9c5176a8cb
7 changed files with 70 additions and 11 deletions
|
@ -211,7 +211,7 @@ class Site:
|
|||
|
||||
|
||||
# Update content.json on peers
|
||||
def publish(self, limit=3, inner_path="content.json"):
|
||||
def publish(self, limit=5, inner_path="content.json"):
|
||||
self.log.info( "Publishing to %s/%s peers..." % (limit, len(self.peers)) )
|
||||
published = [] # Successfuly published (Peer)
|
||||
publishers = [] # Publisher threads
|
||||
|
@ -317,6 +317,27 @@ class Site:
|
|||
self.log.error("Announced to %s trackers, failed" % len(SiteManager.TRACKERS))
|
||||
|
||||
|
||||
# Need open connections
|
||||
def needConnections(self):
|
||||
need = min(len(self.peers)/2, 10) # Connect to half of total peers, but max 10
|
||||
need = max(need, 5) # But minimum 5 peers
|
||||
need = min(len(self.peers), need) # Max total peers
|
||||
|
||||
connected = 0
|
||||
for peer in self.peers.values(): # Check current connected number
|
||||
if peer.connection and peer.connection.connected:
|
||||
connected += 1
|
||||
|
||||
self.log.debug("Need connections: %s, Current: %s, Total: %s" % (need, connected, len(self.peers)))
|
||||
|
||||
if connected < need: # Need more than we have
|
||||
for peer in self.peers.values():
|
||||
if not peer.connection or not peer.connection.connected: # No peer connection or disconnected
|
||||
peer.connect()
|
||||
if peer.connection and peer.connection.connected: connected += 1 # Successfully connected
|
||||
if connected >= need: break
|
||||
return connected
|
||||
|
||||
|
||||
|
||||
# - Events -
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue