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

Method subscribe

plugins/src/lib.rs:182–198  ·  view source on GitHub ↗

Subscribe to notifications for the given `topic`. The handler is an async function that takes a `Plugin ` and the notification as a `serde_json::Value` as inputs. Since notifications do not expect a result the handler should only report errors while processing. Any error reported while processing the notification will be logged in the cln logs. ``` use cln_plugin::{options, Builder, Error, Plug

(mut self, topic: &str, callback: C)

Source from the content-addressed store, hash-verified

180 /// .subscribe("connect", connect_handler);
181 /// ```
182 pub fn subscribe<C, F>(mut self, topic: &str, callback: C) -> Builder<S, I, O>
183 where
184 C: Send + Sync + 'static,
185 C: Fn(Plugin<S>, Request) -> F + 'static,
186 F: Future<Output = Result<(), Error>> + Send + 'static,
187 {
188 let subscription = Subscription {
189 callback: Box::new(move |p, r| Box::pin(callback(p, r))),
190 };
191
192 if topic == "*" {
193 self.wildcard_subscription = Some(subscription);
194 } else {
195 self.subscriptions.insert(topic.to_string(), subscription);
196 };
197 self
198 }
199
200 /// Add a hook subscription for `hookname` with a raw [`serde_json::Value`] request and response.
201 /// Prefer [`Builder::hook_typed`] for type-safe hooks, or [`Builder::hook_from_builder`] if you

Callers 6

mainFunction · 0.45
mainFunction · 0.45
joinMethod · 0.45
mainFunction · 0.45
mainFunction · 0.45
htlc_accepted_handlerFunction · 0.45

Calls 2

insertMethod · 0.45
to_stringMethod · 0.45

Tested by

no test coverage detected