Define len() for network.BMConnectionPool
This commit is contained in:
parent
1035d2aec4
commit
f9dc8eaacf
|
@ -597,8 +597,7 @@ class BMProto(AdvancedDispatcher, ObjectTracker):
|
||||||
if (
|
if (
|
||||||
Peer(self.destination.host, self.peerNode.port)
|
Peer(self.destination.host, self.peerNode.port)
|
||||||
in connectionpool.BMConnectionPool().inboundConnections
|
in connectionpool.BMConnectionPool().inboundConnections
|
||||||
or len(connectionpool.BMConnectionPool().inboundConnections)
|
or len(connectionpool.BMConnectionPool())
|
||||||
+ len(connectionpool.BMConnectionPool().outboundConnections)
|
|
||||||
> BMConfigParser().safeGetInt(
|
> BMConfigParser().safeGetInt(
|
||||||
'bitmessagesettings', 'maxtotalconnections')
|
'bitmessagesettings', 'maxtotalconnections')
|
||||||
+ BMConfigParser().safeGetInt(
|
+ BMConfigParser().safeGetInt(
|
||||||
|
|
|
@ -72,6 +72,9 @@ class BMConnectionPool(object):
|
||||||
' trustedpeer=<hostname>:<portnumber>'
|
' trustedpeer=<hostname>:<portnumber>'
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def __len__(self):
|
||||||
|
return len(self.outboundConnections) + len(self.inboundConnections)
|
||||||
|
|
||||||
def connections(self):
|
def connections(self):
|
||||||
"""
|
"""
|
||||||
Shortcut for combined list of connections from
|
Shortcut for combined list of connections from
|
||||||
|
|
|
@ -408,8 +408,7 @@ class TCPServer(AdvancedDispatcher):
|
||||||
|
|
||||||
state.ownAddresses[Peer(*sock.getsockname())] = True
|
state.ownAddresses[Peer(*sock.getsockname())] = True
|
||||||
if (
|
if (
|
||||||
len(connectionpool.BMConnectionPool().inboundConnections)
|
len(connectionpool.BMConnectionPool())
|
||||||
+ len(connectionpool.BMConnectionPool().outboundConnections)
|
|
||||||
> BMConfigParser().safeGetInt(
|
> BMConfigParser().safeGetInt(
|
||||||
'bitmessagesettings', 'maxtotalconnections')
|
'bitmessagesettings', 'maxtotalconnections')
|
||||||
+ BMConfigParser().safeGetInt(
|
+ BMConfigParser().safeGetInt(
|
||||||
|
|
Reference in New Issue
Block a user