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
This commit is contained in:
parent
ca567acab3
commit
3a4eed0f8b
|
@ -26,7 +26,6 @@ from queues import objectProcessorQueue, portCheckerQueue, invQueue, addrQueue
|
||||||
import shared
|
import shared
|
||||||
import state
|
import state
|
||||||
import protocol
|
import protocol
|
||||||
import helper_random
|
|
||||||
|
|
||||||
class BMProtoError(ProxyError):
|
class BMProtoError(ProxyError):
|
||||||
errorCodes = ("Protocol error")
|
errorCodes = ("Protocol error")
|
||||||
|
@ -280,11 +279,11 @@ class BMProto(AdvancedDispatcher, ObjectTracker):
|
||||||
def bm_command_getdata(self):
|
def bm_command_getdata(self):
|
||||||
items = self.decode_payload_content("l32s")
|
items = self.decode_payload_content("l32s")
|
||||||
# skip?
|
# skip?
|
||||||
if time.time() < self.skipUntil:
|
now = time.time()
|
||||||
|
if now < self.skipUntil:
|
||||||
return True
|
return True
|
||||||
helper_random.randomshuffle(items)
|
|
||||||
for i in map(str, items):
|
for i in map(str, items):
|
||||||
self.pendingUpload[i] = time.time()
|
self.pendingUpload[i] = now
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def _command_inv(self, dandelion=False):
|
def _command_inv(self, dandelion=False):
|
||||||
|
|
Reference in New Issue
Block a user