From 3a4eed0f8b84f7ed4ce6ac5d4634a256b9fb148a Mon Sep 17 00:00:00 2001 From: Peter Surda Date: Wed, 19 Dec 2018 09:38:38 +0100 Subject: [PATCH] getdata performance optimisation - reduce number of calls to time.time() - no need to shuffle, that's done by the upload thread - get rid of unused import --- src/network/bmproto.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/network/bmproto.py b/src/network/bmproto.py index c5bc9263..8b96bb38 100644 --- a/src/network/bmproto.py +++ b/src/network/bmproto.py @@ -26,7 +26,6 @@ from queues import objectProcessorQueue, portCheckerQueue, invQueue, addrQueue import shared import state import protocol -import helper_random class BMProtoError(ProxyError): errorCodes = ("Protocol error") @@ -280,11 +279,11 @@ class BMProto(AdvancedDispatcher, ObjectTracker): def bm_command_getdata(self): items = self.decode_payload_content("l32s") # skip? - if time.time() < self.skipUntil: + now = time.time() + if now < self.skipUntil: return True - helper_random.randomshuffle(items) for i in map(str, items): - self.pendingUpload[i] = time.time() + self.pendingUpload[i] = now return True def _command_inv(self, dandelion=False):