Define len() for network.BMConnectionPool
This commit is contained in:
parent
1035d2aec4
commit
f9dc8eaacf
|
@ -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(
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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(
|
||||
|
|
Reference in New Issue
Block a user