Try to rewrite sending big invs not using sets
This commit is contained in:
parent
d106078dac
commit
c4a470233b
|
@ -277,22 +277,19 @@ class ConnectionBase(threading.Thread):
|
||||||
if len(addr) != 0:
|
if len(addr) != 0:
|
||||||
self.send_queue.put(message.Addr(addr))
|
self.send_queue.put(message.Addr(addr))
|
||||||
|
|
||||||
with shared.objects_lock:
|
if len(shared.objects) > 0:
|
||||||
if len(shared.objects) > 0:
|
with shared.objects_lock:
|
||||||
to_send = {
|
to_send = [
|
||||||
vector for vector in shared.objects.keys()
|
vector for vector in shared.objects.keys()
|
||||||
if shared.objects[vector].expires_time > time.time()}
|
if shared.objects[vector].expires_time > time.time()]
|
||||||
while len(to_send) > 0:
|
random.shuffle(to_send)
|
||||||
if len(to_send) > 10000:
|
offset = 0
|
||||||
# We limit size of inv messaged to 10000 entries
|
while offset < len(to_send):
|
||||||
# because they might time out
|
# We limit size of inv messaged to 10000 entries
|
||||||
# in very slow networks (I2P)
|
# because they might time out
|
||||||
pack = random.sample(tuple(to_send), 10000)
|
# in very slow networks (I2P)
|
||||||
self.send_queue.put(message.Inv(pack))
|
self.send_queue.put(message.Inv(to_send[offset:offset+10000]))
|
||||||
to_send.difference_update(pack)
|
offset += 10000
|
||||||
else:
|
|
||||||
self.send_queue.put(message.Inv(to_send))
|
|
||||||
to_send.clear()
|
|
||||||
self.status = 'fully_established'
|
self.status = 'fully_established'
|
||||||
|
|
||||||
def _process_queue(self):
|
def _process_queue(self):
|
||||||
|
|
Loading…
Reference in New Issue
Block a user