Open felipedau opened 7 years ago
However, I am going to leave this open because I am not happy with
the solution. We depend on #57 to define the exact sizes of each part
of a packet and send only bytes. from_element()
shouldn't expect the
data to increase 34% due to the base64 encoding.
What has to be done:
Once #57 is implemented, see if we can estimate the final size of
elements and packets with the .*_LEN
constants in peer.py
or if
we need to actually calculate
Modify from_element()
based on the decision above
Future work:
Creating the parts of a partial element from an element is using a lot of CPU for long elements
In general I think that keeping everything in memory is good, but then we use a lot of resources when dealing with long elements
Assigning just the payloads to the partial element and then creating the element packets from them may not be doing a good use of memory - maybe the packets should be assigned to the partial element right away
Once #57 and #58 are implemented, long elements will have to be split into multiple element packets. Most of this has already been done:
PartialElement
is created if it did not exist already and the contents of that packet is added to its respective part in thePartialElement
's dictionaryPartialElement.is_complete
tells if all parts were received,__str__()
joins them andto_element()
returns a complete and deserializedElement
PartialElement.from_element()
receives an element and its ID, serializes it and returns aPartialElement
with a single part with the whole elementPartialElement.to_packets()
builds and returnsElementPacket
s containing each partPartialElement.from_element()
splits the serialized element based on themax_len
argument