1414import addresses
1515import protocol
1616import state
17- from . import connectionpool
1817from . import knownnodes
1918from bmconfigparser import config
2019from queues import objectProcessorQueue
@@ -395,27 +394,27 @@ def bm_command_object(self):
395394 self .object .checkAlreadyHave ()
396395 except (BMObjectExpiredError , BMObjectAlreadyHaveError ,
397396 BMObjectInsufficientPOWError ):
398- BMProto .stopDownloadingObject (self .object .inventoryHash )
397+ self .stopDownloadingObject (self .object .inventoryHash )
399398 raise
400399 try :
401- self .object .checkStream ()
400+ self .object .checkStream (self . pool . streams )
402401 except BMObjectUnwantedStreamError :
403402 acceptmismatch = config .getboolean (
404403 "inventory" , "acceptmismatch" )
405- BMProto .stopDownloadingObject (
404+ self .stopDownloadingObject (
406405 self .object .inventoryHash , acceptmismatch )
407406 if not acceptmismatch :
408407 raise
409408 except BMObjectInvalidError :
410- BMProto .stopDownloadingObject (self .object .inventoryHash )
409+ self .stopDownloadingObject (self .object .inventoryHash )
411410 raise
412411
413412 try :
414413 self .object .checkObjectByType ()
415414 objectProcessorQueue .put ((
416415 self .object .objectType , buffer (self .object .data ))) # noqa: F821
417416 except BMObjectInvalidError :
418- BMProto .stopDownloadingObject (self .object .inventoryHash , True )
417+ self .stopDownloadingObject (self .object .inventoryHash , True )
419418 else :
420419 try :
421420 del missingObjects [self .object .inventoryHash ]
@@ -448,7 +447,7 @@ def bm_command_addr(self):
448447 for seenTime , stream , _ , ip , port in self ._decode_addr ():
449448 ip = str (ip )
450449 if (
451- stream not in connectionpool .pool .streams
450+ stream not in self .pool .streams
452451 # FIXME: should check against complete list
453452 or ip .startswith ('bootstrap' )
454453 ):
@@ -547,7 +546,7 @@ def bm_command_version(self):
547546 if not self .isOutbound :
548547 self .append_write_buf (protocol .assembleVersionMessage (
549548 self .destination .host , self .destination .port ,
550- connectionpool .pool .streams , dandelion_ins .enabled , True ,
549+ self .pool .streams , dandelion_ins .enabled , True ,
551550 nodeid = self .nodeid ))
552551 logger .debug (
553552 '%(host)s:%(port)i sending version' ,
@@ -603,7 +602,7 @@ def peerValidityChecks(self):
603602 'Closed connection to %s because there is no overlapping'
604603 ' interest in streams.' , self .destination )
605604 return False
606- if connectionpool .pool .inboundConnections .get (
605+ if self .pool .inboundConnections .get (
607606 self .destination ):
608607 try :
609608 if not protocol .checkSocksIP (self .destination .host ):
@@ -621,8 +620,8 @@ def peerValidityChecks(self):
621620 # or server full report the same error to counter deanonymisation
622621 if (
623622 Peer (self .destination .host , self .peerNode .port )
624- in connectionpool .pool .inboundConnections
625- or len (connectionpool .pool )
623+ in self .pool .inboundConnections
624+ or len (self .pool )
626625 > config .safeGetInt (
627626 'bitmessagesettings' , 'maxtotalconnections' )
628627 + config .safeGetInt (
@@ -634,7 +633,7 @@ def peerValidityChecks(self):
634633 'Closed connection to %s due to server full'
635634 ' or duplicate inbound/outbound.' , self .destination )
636635 return False
637- if connectionpool .pool .isAlreadyConnected (self .nonce ):
636+ if self .pool .isAlreadyConnected (self .nonce ):
638637 self .append_write_buf (protocol .assembleErrorMessage (
639638 errorText = "I'm connected to myself. Closing connection." ,
640639 fatal = 2 ))
@@ -645,10 +644,9 @@ def peerValidityChecks(self):
645644
646645 return True
647646
648- @staticmethod
649- def stopDownloadingObject (hashId , forwardAnyway = False ):
647+ def stopDownloadingObject (self , hashId , forwardAnyway = False ):
650648 """Stop downloading object *hashId*"""
651- for connection in connectionpool .pool .connections ():
649+ for connection in self .pool .connections ():
652650 try :
653651 del connection .objectsNewToMe [hashId ]
654652 except KeyError :
0 commit comments