Separating construction of bytestring of all known nodes so that it can be used more easily in tests.

pull/1451/head
jMyles 2019-11-10 02:56:22 -08:00
parent 6a336aecbd
commit 5a563999c6
1 changed files with 10 additions and 0 deletions

View File

@ -1008,6 +1008,16 @@ class Teacher:
nodes_to_consider = list(self.known_nodes.values()) + [self]
return sorted(nodes_to_consider, key=lambda n: n.checksum_address)
def bytestring_of_known_nodes(self):
payload = self.known_nodes.snapshot()
ursulas_as_vbytes = (VariableLengthBytestring(n) for n in self.known_nodes)
ursulas_as_bytes = bytes().join(bytes(u) for u in ursulas_as_vbytes)
ursulas_as_bytes += VariableLengthBytestring(bytes(self))
payload += ursulas_as_bytes
return payload
def update_snapshot(self, checksum, updated, number_of_known_nodes):
"""
TODO: We update the simple snapshot here, but of course if we're dealing