diff --git a/src/network/bmproto.py b/src/network/bmproto.py index 6c23a234..ef64de94 100644 --- a/src/network/bmproto.py +++ b/src/network/bmproto.py @@ -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( diff --git a/src/network/connectionpool.py b/src/network/connectionpool.py index 77eb58e4..fffc0bc3 100644 --- a/src/network/connectionpool.py +++ b/src/network/connectionpool.py @@ -72,6 +72,9 @@ class BMConnectionPool(object): ' trustedpeer=:' ) + def __len__(self): + return len(self.outboundConnections) + len(self.inboundConnections) + def connections(self): """ Shortcut for combined list of connections from diff --git a/src/network/tcp.py b/src/network/tcp.py index df4c9a75..320e776a 100644 --- a/src/network/tcp.py +++ b/src/network/tcp.py @@ -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(