Flood mitigation was done both in the ObjectProcessorQueue as well as
receiveData threads. This patch removes the mitigation in receiveData
threads and cleans up the one in the ObjectProcessorQueue
sqlExecute('''DELETE FROM objectprocessorqueue''')
logger.debug('Loaded %s objects from disk into the objectProcessorQueue.'%str(len(queryreturn)))
@ -70,19 +68,14 @@ class objectProcessor(threading.Thread):
exceptExceptionase:
logger.critical("Critical error within objectProcessorThread: \n%s"%traceback.format_exc())
withshared.objectProcessorQueueSizeLock:
shared.objectProcessorQueueSize-=len(data)# We maintain objectProcessorQueueSize so that we will slow down requesting objects if too much data accumulates in the queue.
ifshared.shutdown:
time.sleep(.5)# Wait just a moment for most of the connections to close
sql.execute('''INSERT INTO objectprocessorqueue VALUES (?,?)''',
objectType,data)
withshared.objectProcessorQueueSizeLock:
shared.objectProcessorQueueSize-=len(data)# We maintain objectProcessorQueueSize so that we will slow down requesting objects if too much data accumulates in the queue.
logger.debug('Saved %s objects from the objectProcessorQueue to disk. objectProcessorThread exiting.'%str(numberOfObjectsThatWereInTheObjectProcessorQueue))
@ -50,8 +51,6 @@ sendDataQueues = [] #each sendData thread puts its queue in this list.
inventory={}#of objects (like msg payloads and pubkey payloads) Does not include protocol headers (the first 24 bytes of each packet).
inventoryLock=threading.Lock()#Guarantees that two receiveDataThreads don't receive and process the same message concurrently (probably sent by a malicious individual)
printLock=threading.Lock()
objectProcessorQueueSizeLock=threading.Lock()
objectProcessorQueueSize=0# in Bytes. We maintain this to prevent nodes from flooing us with objects which take up too much memory. If this gets too big we'll sleep before asking for further objects.
appdata=''#holds the location of the application data storage directory
statusIconColor='red'
connectedHostsList={}#List of hosts to which we are connected. Used to guarantee that the outgoingSynSender threads won't connect to the same remote node twice.
@ -87,8 +86,7 @@ daemon = False
inventorySets={1:set()}# key = streamNumer, value = a set which holds the inventory object hashes that we are aware of. This is used whenever we receive an inv message from a peer to check to see what items are new to us. We don't delete things out of it; instead, the singleCleaner thread clears and refills it every couple hours.
needToWriteKnownNodesToDisk=False# If True, the singleCleaner will write it to disk eventually.
maximumLengthOfTimeToBotherResendingMessages=0
objectProcessorQueue=Queue.Queue(
)# receiveDataThreads dump objects they hear on the network into this queue to be processed.
objectProcessorQueue=ObjectProcessorQueue()# receiveDataThreads dump objects they hear on the network into this queue to be processed.
streamsInWhichIAmParticipating={}
# sanity check, prevent doing ridiculous PoW
@ -397,10 +395,7 @@ def doCleanShutdown():
globalshutdown
shutdown=1#Used to tell proof of work worker threads and the objectProcessorThread to exit.