Quicker message downloading
This commit is contained in:
parent
b7b81a2c56
commit
4f608ba75a
|
@ -68,7 +68,7 @@ class Connection(threading.Thread):
|
||||||
if self.status == 'fully_established':
|
if self.status == 'fully_established':
|
||||||
data = self.s.recv(4096)
|
data = self.s.recv(4096)
|
||||||
self.buffer_receive += data
|
self.buffer_receive += data
|
||||||
if data and len(self.buffer_receive) < self.next_message_size:
|
if data and len(self.buffer_receive) < 4000000:
|
||||||
continue
|
continue
|
||||||
else:
|
else:
|
||||||
data = self.s.recv(self.next_message_size - len(self.buffer_receive))
|
data = self.s.recv(self.next_message_size - len(self.buffer_receive))
|
||||||
|
@ -233,7 +233,6 @@ class Connection(threading.Thread):
|
||||||
logging.debug('{}:{} -> {}'.format(self.host, self.port, inv))
|
logging.debug('{}:{} -> {}'.format(self.host, self.port, inv))
|
||||||
to_get = inv.vectors.copy()
|
to_get = inv.vectors.copy()
|
||||||
to_get.difference_update(shared.objects.keys())
|
to_get.difference_update(shared.objects.keys())
|
||||||
to_get.difference_update(shared.requested_objects)
|
|
||||||
self.vectors_to_get.update(to_get)
|
self.vectors_to_get.update(to_get)
|
||||||
elif m.command == b'object':
|
elif m.command == b'object':
|
||||||
obj = structure.Object.from_message(m)
|
obj = structure.Object.from_message(m)
|
||||||
|
@ -265,12 +264,6 @@ class Connection(threading.Thread):
|
||||||
pack = random.sample(self.vectors_to_get, 50000)
|
pack = random.sample(self.vectors_to_get, 50000)
|
||||||
self.send_queue.put(message.GetData(pack))
|
self.send_queue.put(message.GetData(pack))
|
||||||
self.vectors_to_get.difference_update(pack)
|
self.vectors_to_get.difference_update(pack)
|
||||||
if shared.conserve_bandwidth:
|
|
||||||
with shared.requested_objects_lock:
|
|
||||||
shared.requested_objects.update(pack)
|
|
||||||
else:
|
else:
|
||||||
self.send_queue.put(message.GetData(self.vectors_to_get))
|
self.send_queue.put(message.GetData(self.vectors_to_get))
|
||||||
if shared.conserve_bandwidth:
|
|
||||||
with shared.requested_objects_lock:
|
|
||||||
shared.requested_objects.update(self.vectors_to_get)
|
|
||||||
self.vectors_to_get.clear()
|
self.vectors_to_get.clear()
|
||||||
|
|
Loading…
Reference in New Issue
Block a user