WIP: Implementing sqlite objects storage #13

Draft
lee.miller wants to merge 11 commits from lee.miller/MiNode:sqlite into v0.3
3 changed files with 9 additions and 9 deletions
Showing only changes of commit 0198df4948 - Show all commits

View File

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

View File

@ -154,7 +154,8 @@ class Inventory():
self._pending.update(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:
stream = shared.stream
now = int(time.time())

View File

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