99import protocol
1010import state
1111from network .connectionpool import BMConnectionPool
12- from network .dandelion import Dandelion
1312from queues import invQueue
1413from threads import StoppableThread
1514
@@ -40,10 +39,10 @@ class InvThread(StoppableThread):
4039 @staticmethod
4140 def handleLocallyGenerated (stream , hashId ):
4241 """Locally generated inventory items require special handling"""
43- Dandelion () .addHash (hashId , stream = stream )
42+ state . Dandelion .addHash (hashId , stream = stream )
4443 for connection in BMConnectionPool ().connections ():
4544 if state .dandelion and connection != \
46- Dandelion () .objectChildStem (hashId ):
45+ state . Dandelion .objectChildStem (hashId ):
4746 continue
4847 connection .objectsNewToThem [hashId ] = time ()
4948
@@ -52,7 +51,7 @@ def run(self): # pylint: disable=too-many-branches
5251 chunk = []
5352 while True :
5453 # Dandelion fluff trigger by expiration
55- handleExpiredDandelion (Dandelion () .expire ())
54+ handleExpiredDandelion (state . Dandelion .expire ())
5655 try :
5756 data = invQueue .get (False )
5857 chunk .append ((data [0 ], data [1 ]))
@@ -75,7 +74,7 @@ def run(self): # pylint: disable=too-many-branches
7574 except KeyError :
7675 continue
7776 try :
78- if connection == Dandelion () .objectChildStem (inv [1 ]):
77+ if connection == state . Dandelion .objectChildStem (inv [1 ]):
7978 # Fluff trigger by RNG
8079 # auto-ignore if config set to 0, i.e. dandelion is off
8180 if random .randint (1 , 100 ) >= state .dandelion : # nosec B311
@@ -105,7 +104,7 @@ def run(self): # pylint: disable=too-many-branches
105104 for _ in range (len (chunk )):
106105 invQueue .task_done ()
107106
108- if Dandelion () .refresh < time ():
109- Dandelion () .reRandomiseStems ()
107+ if state . Dandelion .refresh < time ():
108+ state . Dandelion .reRandomiseStems ()
110109
111110 self .stop .wait (1 )
0 commit comments