mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-23 17:14:22 +01:00
pyln-proto: write out length of arrays of subtypes to wire
We weren't writing out the length of a nested subtype's dynamicarraylenght, now we do. The trick is to iterate through the fields on a subtype (since the length field is added separately) and to also iterate down through the otherfield values as we 'descend'
This commit is contained in:
@@ -297,10 +297,17 @@ other types. Since 'msgtype' is almost identical, it inherits from this too.
|
||||
|
||||
def write(self, io_out: BufferedIOBase, v: Dict[str, Any], otherfields: Dict[str, Any]) -> None:
|
||||
self._raise_if_badvals(v)
|
||||
for fname, val in v.items():
|
||||
field = self.find_field(fname)
|
||||
assert field
|
||||
field.fieldtype.write(io_out, val, otherfields)
|
||||
for f in self.fields:
|
||||
if f.name in v:
|
||||
val = v[f.name]
|
||||
else:
|
||||
if f.option is not None:
|
||||
raise ValueError("Missing field {} {}".format(f.name, otherfields))
|
||||
val = None
|
||||
|
||||
if self.name in otherfields:
|
||||
otherfields = otherfields[self.name]
|
||||
f.fieldtype.write(io_out, val, otherfields)
|
||||
|
||||
def read(self, io_in: BufferedIOBase, otherfields: Dict[str, Any]) -> Optional[Dict[str, Any]]:
|
||||
vals = {}
|
||||
|
||||
Reference in New Issue
Block a user