mirror of
https://github.com/aljazceru/lightning.git
synced 2026-01-04 14:54:26 +01:00
msggen: Use the inferred optional field
Changelog-Changed: msggen: The generated interfaces `cln-rpc` anc `cln-grpc` can now work with a range of versions rather than having to match the CLN version
This commit is contained in:
committed by
Rusty Russell
parent
392cacac81
commit
60b12ec096
4
cln-grpc/proto/node.proto
generated
4
cln-grpc/proto/node.proto
generated
@@ -131,7 +131,7 @@ message ListpeersResponse {
|
||||
message ListpeersPeers {
|
||||
bytes id = 1;
|
||||
bool connected = 2;
|
||||
uint32 num_channels = 8;
|
||||
optional uint32 num_channels = 8;
|
||||
repeated ListpeersPeersLog log = 3;
|
||||
repeated ListpeersPeersChannels channels = 4;
|
||||
repeated string netaddr = 5;
|
||||
@@ -303,7 +303,7 @@ message ListfundsChannels {
|
||||
uint32 funding_output = 5;
|
||||
bool connected = 6;
|
||||
ChannelState state = 7;
|
||||
bytes channel_id = 9;
|
||||
optional bytes channel_id = 9;
|
||||
optional string short_channel_id = 8;
|
||||
}
|
||||
|
||||
|
||||
8
cln-grpc/src/convert.rs
generated
8
cln-grpc/src/convert.rs
generated
@@ -212,7 +212,7 @@ impl From<responses::ListpeersPeers> for pb::ListpeersPeers {
|
||||
Self {
|
||||
id: c.id.serialize().to_vec(), // Rule #2 for type pubkey
|
||||
connected: c.connected, // Rule #2 for type boolean
|
||||
num_channels: c.num_channels, // Rule #2 for type u32
|
||||
num_channels: c.num_channels, // Rule #2 for type u32?
|
||||
log: c.log.map(|arr| arr.into_iter().map(|i| i.into()).collect()).unwrap_or(vec![]), // Rule #3
|
||||
channels: c.channels.map(|arr| arr.into_iter().map(|i| i.into()).collect()).unwrap_or(vec![]), // Rule #3
|
||||
netaddr: c.netaddr.map(|arr| arr.into_iter().map(|i| i.into()).collect()).unwrap_or(vec![]), // Rule #3
|
||||
@@ -259,7 +259,7 @@ impl From<responses::ListfundsChannels> for pb::ListfundsChannels {
|
||||
funding_output: c.funding_output, // Rule #2 for type u32
|
||||
connected: c.connected, // Rule #2 for type boolean
|
||||
state: c.state as i32,
|
||||
channel_id: c.channel_id.to_vec(), // Rule #2 for type hash
|
||||
channel_id: c.channel_id.map(|v| v.to_vec()), // Rule #2 for type hash?
|
||||
short_channel_id: c.short_channel_id.map(|v| v.to_string()), // Rule #2 for type short_channel_id?
|
||||
}
|
||||
}
|
||||
@@ -2550,7 +2550,7 @@ impl From<pb::ListpeersPeers> for responses::ListpeersPeers {
|
||||
Self {
|
||||
id: PublicKey::from_slice(&c.id).unwrap(), // Rule #1 for type pubkey
|
||||
connected: c.connected, // Rule #1 for type boolean
|
||||
num_channels: c.num_channels, // Rule #1 for type u32
|
||||
num_channels: c.num_channels, // Rule #1 for type u32?
|
||||
log: Some(c.log.into_iter().map(|s| s.into()).collect()), // Rule #4
|
||||
channels: Some(c.channels.into_iter().map(|s| s.into()).collect()), // Rule #4
|
||||
netaddr: Some(c.netaddr.into_iter().map(|s| s.into()).collect()), // Rule #4
|
||||
@@ -2597,7 +2597,7 @@ impl From<pb::ListfundsChannels> for responses::ListfundsChannels {
|
||||
funding_output: c.funding_output, // Rule #1 for type u32
|
||||
connected: c.connected, // Rule #1 for type boolean
|
||||
state: c.state.try_into().unwrap(),
|
||||
channel_id: Sha256::from_slice(&c.channel_id).unwrap(), // Rule #1 for type hash
|
||||
channel_id: c.channel_id.map(|v| Sha256::from_slice(&v).unwrap()), // Rule #1 for type hash?
|
||||
short_channel_id: c.short_channel_id.map(|v| cln_rpc::primitives::ShortChannelId::from_str(&v).unwrap()), // Rule #1 for type short_channel_id?
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user