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

Method dispatch_custom_notification

plugins/src/lib.rs:623–653  ·  view source on GitHub ↗
(
        &self,
        notification: serde_json::Value,
        plugin: &Plugin<S>,
    )

Source from the content-addressed store, hash-verified

621 }
622
623 async fn dispatch_custom_notification(
624 &self,
625 notification: serde_json::Value,
626 plugin: &Plugin<S>,
627 ) -> Result<(), Error>
628 where
629 S: Send + Clone,
630 {
631 trace!("Dispatching custom notification {:?}", notification);
632 let method = notification
633 .get("method")
634 .context("Missing 'method' in notification")?
635 .as_str()
636 .context("'method' is not a string")?;
637 let params = notification
638 .get("params")
639 .context("Missing 'params' field in notification")?;
640 let callback = self
641 .subscriptions
642 .get(method)
643 .with_context(|| anyhow!("No handler for method '{}' registered", method))?;
644 trace!(
645 "Dispatching custom request: method={}, params={}",
646 method,
647 params
648 );
649 if let Err(e) = callback(plugin.clone(), params.clone()).await {
650 log::error!("Error in notification handler '{}': {}", method, e);
651 }
652 Ok(())
653 }
654}
655
656impl<S> Plugin<S>

Callers 1

dispatch_oneMethod · 0.80

Calls 1

getMethod · 0.80

Tested by

no test coverage detected