mirror of
https://github.com/ElementsProject/lightning.git
synced 2024-11-19 09:54:16 +01:00
cln-plugin: Configuration struct
Represents the "configuration" part of the "init" message during plugin initialization. Changelog-Added: cln_plugin: persist cln configuration from init msg
This commit is contained in:
parent
318b6e803e
commit
5ec424bc86
@ -3,7 +3,7 @@ pub use anyhow::{anyhow, Context};
|
||||
use futures::sink::SinkExt;
|
||||
extern crate log;
|
||||
use log::trace;
|
||||
use serde::Deserialize;
|
||||
use messages::Configuration;
|
||||
use std::collections::HashMap;
|
||||
use std::future::Future;
|
||||
use std::pin::Pin;
|
||||
@ -210,7 +210,9 @@ where
|
||||
let plugin = Plugin {
|
||||
state: self.state,
|
||||
options: self.options,
|
||||
configuration: self.configuration.unwrap(), // OK to unwrap, set in handle_init
|
||||
configuration: self
|
||||
.configuration
|
||||
.ok_or(anyhow!("Plugin configuration missing"))?,
|
||||
wait_handle,
|
||||
sender,
|
||||
};
|
||||
@ -368,7 +370,9 @@ where
|
||||
{
|
||||
/// The state gets cloned for each request
|
||||
state: S,
|
||||
/// "options" field of "init" message sent by cln
|
||||
options: Vec<ConfigOption>,
|
||||
/// "configuration" field of "init" message sent by cln
|
||||
configuration: Configuration,
|
||||
/// A signal that allows us to wait on the plugin's shutdown.
|
||||
wait_handle: tokio::sync::broadcast::Sender<()>,
|
||||
@ -662,12 +666,6 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Deserialize)]
|
||||
pub struct Configuration {
|
||||
#[serde(rename = "lightning-dir")]
|
||||
pub lightning_dir: String,
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use super::*;
|
||||
|
@ -1,5 +1,4 @@
|
||||
use crate::options::ConfigOption;
|
||||
use crate::Configuration;
|
||||
use serde::de::{self, Deserializer};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use serde_json::Value;
|
||||
@ -67,6 +66,29 @@ pub(crate) struct InitCall {
|
||||
pub(crate) configuration: Configuration,
|
||||
}
|
||||
|
||||
#[derive(Clone, Deserialize, Debug)]
|
||||
pub struct Configuration {
|
||||
#[serde(rename = "lightning-dir")]
|
||||
pub lightning_dir: String,
|
||||
#[serde(rename = "rpc-file")]
|
||||
pub rpc_file: String,
|
||||
pub startup: bool,
|
||||
pub network: String,
|
||||
pub feature_set: HashMap<String, String>,
|
||||
pub proxy: ProxyInfo,
|
||||
#[serde(rename = "torv3-enabled")]
|
||||
pub torv3_enabled: bool,
|
||||
pub always_use_proxy: bool,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Deserialize)]
|
||||
pub struct ProxyInfo {
|
||||
#[serde(alias = "type")]
|
||||
pub typ: String,
|
||||
pub address: String,
|
||||
pub port: i64,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub enum JsonRpc<N, R> {
|
||||
Request(usize, R),
|
||||
|
Loading…
Reference in New Issue
Block a user