From c5a47c314911435801dae7ef6a8317f579b98921 Mon Sep 17 00:00:00 2001 From: Erik De Smedt Date: Tue, 13 Feb 2024 10:46:55 +0100 Subject: [PATCH] msggen: RequestStructs for notification-streams I'm working to expose a stream of notifications over grpc. This requries me to define structs that can be used to request a stream of notifications. These structs are all empty. --- cln-rpc/src/notifications.rs | 24 +++++++++++++++++++ contrib/msggen/msggen/gen/grpc/convert.py | 2 +- contrib/msggen/msggen/gen/rpc/notification.py | 7 ++++++ 3 files changed, 32 insertions(+), 1 deletion(-) diff --git a/cln-rpc/src/notifications.rs b/cln-rpc/src/notifications.rs index 69aa97430..564b56795 100644 --- a/cln-rpc/src/notifications.rs +++ b/cln-rpc/src/notifications.rs @@ -82,3 +82,27 @@ pub struct CustomMsgNotification { pub peer_id: PublicKey, } +pub mod requests{ +use serde::{Serialize, Deserialize}; + + #[derive(Clone, Debug, Deserialize, Serialize)] + pub struct StreamBlockAddedRequest { + } + + #[derive(Clone, Debug, Deserialize, Serialize)] + pub struct StreamChannelOpenFailedRequest { + } + + #[derive(Clone, Debug, Deserialize, Serialize)] + pub struct StreamChannelOpenedRequest { + } + + #[derive(Clone, Debug, Deserialize, Serialize)] + pub struct StreamConnectRequest { + } + + #[derive(Clone, Debug, Deserialize, Serialize)] + pub struct StreamCustomMsgRequest { + } + +} diff --git a/contrib/msggen/msggen/gen/grpc/convert.py b/contrib/msggen/msggen/gen/grpc/convert.py index 567681ad5..1cfe6a515 100644 --- a/contrib/msggen/msggen/gen/grpc/convert.py +++ b/contrib/msggen/msggen/gen/grpc/convert.py @@ -152,7 +152,7 @@ class GrpcConverterGenerator(IGenerator): camel_case += word.capitalize() return camel_case - def generate_requests(self, service): + def generate_requests(self, service: Service): for meth in service.methods: req = meth.request self.generate_composite("requests", req) diff --git a/contrib/msggen/msggen/gen/rpc/notification.py b/contrib/msggen/msggen/gen/rpc/notification.py index a997cd6fc..21a20e585 100644 --- a/contrib/msggen/msggen/gen/rpc/notification.py +++ b/contrib/msggen/msggen/gen/rpc/notification.py @@ -45,3 +45,10 @@ class NotificationGenerator(IGenerator): for notification in service.notifications: _, resp_decl = gen_composite(notification.response, self.meta) self.write(resp_decl) + + self.write("pub mod requests{\n") + self.write(" use serde::{Serialize, Deserialize};\n\n") + for notification in service.notifications: + _, req_decl = gen_composite(notification.request, self.meta) + self.write(req_decl, numindent=1) + self.write("}\n")