Define len() for network.BMConnectionPool

This commit is contained in:
Dmitri Bogomolov 2020-06-09 23:00:42 +03:00
parent 1035d2aec4
commit f9dc8eaacf
Signed by untrusted user: g1itch
GPG Key ID: 720A756F18DEED13
3 changed files with 5 additions and 4 deletions

View File

@ -597,8 +597,7 @@ class BMProto(AdvancedDispatcher, ObjectTracker):
if (
Peer(self.destination.host, self.peerNode.port)
in connectionpool.BMConnectionPool().inboundConnections
or len(connectionpool.BMConnectionPool().inboundConnections)
+ len(connectionpool.BMConnectionPool().outboundConnections)
or len(connectionpool.BMConnectionPool())
> BMConfigParser().safeGetInt(
'bitmessagesettings', 'maxtotalconnections')
+ BMConfigParser().safeGetInt(

View File

@ -72,6 +72,9 @@ class BMConnectionPool(object):
' trustedpeer=<hostname>:<portnumber>'
)
def __len__(self):
return len(self.outboundConnections) + len(self.inboundConnections)
def connections(self):
"""
Shortcut for combined list of connections from

View File

@ -408,8 +408,7 @@ class TCPServer(AdvancedDispatcher):
state.ownAddresses[Peer(*sock.getsockname())] = True
if (
len(connectionpool.BMConnectionPool().inboundConnections)
+ len(connectionpool.BMConnectionPool().outboundConnections)
len(connectionpool.BMConnectionPool())
> BMConfigParser().safeGetInt(
'bitmessagesettings', 'maxtotalconnections')
+ BMConfigParser().safeGetInt(