mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-19 07:04:22 +01:00
wiregen: Passing ctx to array helpers that require it
Some of the struct array helpers need to allocate data when deserializing their fields. The `getnodes` reply is one such example that allocates the hostname. Since the change to calling array helpers the getnodes call was broken because it was attempting to allocate off of the entry, which did not have a tal header, thus failing.
This commit is contained in:
committed by
Rusty Russell
parent
d2e19c3735
commit
b2ea4cfd66
@@ -23,6 +23,11 @@ type2size = {
|
||||
'bool': 1
|
||||
}
|
||||
|
||||
# These struct array helpers require a context to allocate from.
|
||||
varlen_structs = [
|
||||
'gossip_getnodes_entry',
|
||||
]
|
||||
|
||||
class FieldType(object):
|
||||
def __init__(self,name):
|
||||
self.name = name
|
||||
@@ -235,8 +240,9 @@ class Message(object):
|
||||
subcalls.append('\t\t{}[i] = fromwire_{}(&cursor, plen);'
|
||||
.format(name, basetype))
|
||||
else:
|
||||
subcalls.append('\t\tfromwire_{}(&cursor, plen, {} + i);'
|
||||
.format(basetype, name))
|
||||
ctx = "ctx, " if basetype in varlen_structs else ""
|
||||
subcalls.append('\t\tfromwire_{}({}&cursor, plen, {} + i);'
|
||||
.format(basetype, ctx, name))
|
||||
|
||||
def print_fromwire(self,is_header):
|
||||
ctx_arg = 'const tal_t *ctx, ' if self.has_variable_fields else ''
|
||||
|
||||
Reference in New Issue
Block a user