From edcba9982bfd291e9a0c4b69c9026ed29b6dd722 Mon Sep 17 00:00:00 2001 From: Peter Surda Date: Wed, 24 May 2017 21:35:50 +0200 Subject: [PATCH] Asyncore getdata processing performance improvement - no need to query DB for existence of each entry --- src/network/bmproto.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/network/bmproto.py b/src/network/bmproto.py index 9a697b13..bf7019d3 100644 --- a/src/network/bmproto.py +++ b/src/network/bmproto.py @@ -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