MCPcopy Create free account
hub / github.com/ElementsProject/lightning / add_data_field

Method add_data_field

tools/generate-wire.py:138–160  ·  view source on GitHub ↗
(self, field_name, type_obj, count=1,
                       comments=[], optional=False,
                       implicit_len_ok=False)

Source from the content-addressed store, hash-verified

136 self.len_fields = {}
137
138 def add_data_field(self, field_name, type_obj, count=1,
139 comments=[], optional=False,
140 implicit_len_ok=False):
141 field = Field(field_name, type_obj,
142 field_comments=comments, optional=optional)
143 if bool(count):
144 try:
145 field.add_count(int(count))
146 except ValueError:
147 if count in self.fields:
148 len_field = self.find_data_field(count)
149 field.add_len_field(len_field)
150 self.len_fields[len_field.name] = len_field
151 else:
152 # '...' means "rest of TLV"
153 assert implicit_len_ok
154 assert count == '...'
155 field.add_implicit_len()
156
157 # You can't have any fields after an implicit-length field.
158 if len(self.fields) != 0:
159 assert not self.fields[next(reversed(self.fields))].is_implicit_len()
160 self.fields[field_name] = field
161
162 def find_data_field(self, field_name):
163 return self.fields[field_name]

Callers

nothing calls this directly

Calls 7

add_countMethod · 0.95
find_data_fieldMethod · 0.95
add_len_fieldMethod · 0.95
add_implicit_lenMethod · 0.95
nextFunction · 0.85
is_implicit_lenMethod · 0.80
FieldClass · 0.70

Tested by

no test coverage detected