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

Method subscribe

plugins/src/lib.rs:181–197  ·  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

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