Rename .vectors_to_send() to .biginv_chunks() preventing ambiguity

This commit is contained in:
Lee Miller 2024-10-31 07:22:41 +02:00
parent 30dc1ee7a9
commit 0198df4948
Signed by: lee.miller
GPG Key ID: 4F97A5EA88F4AB63
3 changed files with 9 additions and 9 deletions

View File

@ -278,10 +278,9 @@ class ConnectionBase(threading.Thread):
self.send_queue.put(message.Addr(addr)) self.send_queue.put(message.Addr(addr))
if shared.objects: if shared.objects:
for chunk in shared.objects.vectors_to_send(10000): for chunk in shared.objects.biginv_chunks(10000):
# We limit size of inv messaged to 10000 entries # We limit size of inv messages to 10000 entries
# because they might time out # because they might time out in very slow networks (I2P)
# in very slow networks (I2P)
self.send_queue.put(message.Inv(chunk)) self.send_queue.put(message.Inv(chunk))
self.status = 'fully_established' self.status = 'fully_established'

View File

@ -154,7 +154,8 @@ class Inventory():
self._pending.update(vectors) self._pending.update(vectors)
return vectors return vectors
def vectors_to_send(self, chunk_size=10000, stream=None): def biginv_chunks(self, chunk_size=10000, stream=None):
"""Generator of vector lists for making the biginv"""
if stream is None: if stream is None:
stream = shared.stream stream = shared.stream
now = int(time.time()) now = int(time.time())

View File

@ -16,7 +16,7 @@ from minode import sql, shared, structure
# + get # + get
# + filter # + filter
# = select # = select
# + vectors_to_send # + biginv_chunks
class TestObjects(): class TestObjects():
@ -46,7 +46,7 @@ class TestObjects():
self.assertEqual(obj.vector, obj1.vector) self.assertEqual(obj.vector, obj1.vector)
self.assertEqual(obj.data, obj1.data) self.assertEqual(obj.data, obj1.data)
def test_vectors_to_send(self): def test_biginv_chunks(self):
"""Check vectors_to_send method""" """Check vectors_to_send method"""
needed = set() needed = set()
for _ in range(10): for _ in range(10):
@ -66,9 +66,9 @@ class TestObjects():
needed.add(obj.vector) needed.add(obj.vector)
self.assertEqual( self.assertEqual(
set(next(self.objects.vectors_to_send(stream=4))), needed) set(next(self.objects.biginv_chunks(stream=4))), needed)
self.assertTrue( self.assertTrue(
set(next(self.objects.vectors_to_send())).difference(needed)) set(next(self.objects.biginv_chunks())).difference(needed))
def test_filter(self): def test_filter(self):
"""Check the objects filtering""" """Check the objects filtering"""