mirror of
https://github.com/aljazceru/lightning.git
synced 2026-01-07 08:04:23 +01:00
msggen: Add RoutehintList as a primitive
This commit is contained in:
committed by
Rusty Russell
parent
ec5cd92580
commit
ef145c7900
@@ -377,7 +377,7 @@ class GrpcUnconverterGenerator(GrpcConverterGenerator):
|
||||
if isinstance(f, ArrayField):
|
||||
typ = f.itemtype.typename
|
||||
mapping = {
|
||||
'hex': f'hex::decode(s).unwrap()',
|
||||
'hex': f'hex::encode(s)',
|
||||
'u32': f's.clone()',
|
||||
}.get(typ, f's.into()')
|
||||
self.write(f"{name}: c.{name}.iter().map(|s| {mapping}).collect(),\n", numindent=3)
|
||||
@@ -410,6 +410,7 @@ class GrpcUnconverterGenerator(GrpcConverterGenerator):
|
||||
'msat|any?': f'c.{name}.as_ref().map(|a| a.into())',
|
||||
'feerate': f'c.{name}.as_ref().unwrap().into()',
|
||||
'feerate?': f'c.{name}.as_ref().map(|a| a.into())',
|
||||
'RoutehintList?': f'c.{name}.clone().map(|rl| rl.into())',
|
||||
}.get(
|
||||
typ,
|
||||
f'c.{name}.clone()' # default to just assignment
|
||||
|
||||
@@ -340,6 +340,7 @@ InvoiceLabelField = PrimitiveField("string", None, None)
|
||||
DatastoreKeyField = ArrayField(itemtype=PrimitiveField("string", None, None), dims=1, path=None, description=None)
|
||||
InvoiceExposeprivatechannelsField = PrimitiveField("boolean", None, None)
|
||||
PayExclude = ArrayField(itemtype=PrimitiveField("string", None, None), dims=1, path=None, description=None)
|
||||
RoutehintListField = PrimitiveField("RoutehintList", None, None)
|
||||
# Override fields with manually managed types, fieldpath -> field mapping
|
||||
overrides = {
|
||||
'Invoice.label': InvoiceLabelField,
|
||||
@@ -350,6 +351,7 @@ overrides = {
|
||||
'ListDatastore.key': DatastoreKeyField,
|
||||
'Invoice.exposeprivatechannels': InvoiceExposeprivatechannelsField,
|
||||
'Pay.exclude': PayExclude,
|
||||
'KeySend.routehints': RoutehintListField,
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -165,7 +165,7 @@ def gen_array(a):
|
||||
return ("", "") # Override said not to include
|
||||
|
||||
itemtype = typemap.get(itemtype, itemtype)
|
||||
alias = a.name.normalized()[:-2] # Strip the `[]` suffix for arrays.
|
||||
alias = a.name.normalized()
|
||||
defi = f" #[serde(alias = \"{alias}\")]\n pub {name}: {'Vec<'*a.dims}{itemtype}{'>'*a.dims},\n"
|
||||
|
||||
return (defi, decl)
|
||||
|
||||
Reference in New Issue
Block a user