Asyncore getdata processing performance improvement

- no need to query DB for existence of each entry
This commit is contained in:
Peter Šurda 2017-05-24 21:35:50 +02:00
parent fa56ab3e6f
commit edcba9982b
Signed by untrusted user: PeterSurda
GPG Key ID: 0C5F50C0B5F37D87

View File

@ -295,9 +295,10 @@ class BMConnection(TLSDispatcher, BMQueues):
if False:
self.antiIntersectionDelay()
else:
if i in Inventory():
try:
self.append_write_buf(protocol.CreatePacket('object', Inventory()[i].payload))
else:
# this is faster than "if i in Inventory()"
except KeyError:
self.antiIntersectionDelay()
logger.warning('%s asked for an object with a getdata which is not in either our memory inventory or our SQL inventory. We probably cleaned it out after advertising it but before they got around to asking for it.' % (self.peer,))
return True