Skip to content

Commit

Permalink
rename LSP objects using more descriptive name
Browse files Browse the repository at this point in the history
  • Loading branch information
johncantrell97 committed Jun 15, 2023
1 parent 6d3c888 commit f8eb772
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 19 deletions.
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@ mod jit_channel;
mod transport;
mod utils;

pub use transport::message_handler::{LSPConfig, LSPManager};
pub use transport::message_handler::{LiquidityManager, LiquidityProviderConfig};
33 changes: 15 additions & 18 deletions src/transport/message_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,37 +30,34 @@ pub(crate) trait ProtocolMessageHandler {
) -> Result<(), LightningError>;
}

/// A configuration for [`LSPManager`].
/// A configuration for [`LiquidityManager`].
///
/// Allows end-user to configure options for both client and server
/// usage of the [`LSPManager`].
pub struct LSPConfig {
/// Indicates whether or not you intend to provide services.
is_lsp: bool,
}
/// Allows end-user to configure options when using the [`LiquidityManager`]
/// to provide liquidity services to clients.
pub struct LiquidityProviderConfig;

/// The main interface into LSP functionality.
///
/// Should be used as a [`CustomMessageHandler`] for your
/// [`lightning::ln::peer_handler::PeerManager`]'s [`lightning::ln::peer_handler::MessageHandler`].
pub struct LSPManager<ES: Deref>
pub struct LiquidityManager<ES: Deref>
where
ES::Target: EntropySource,
{
pending_messages: Arc<Mutex<Vec<(PublicKey, LSPSMessage)>>>,
request_id_to_method_map: Mutex<HashMap<String, String>>,
lsps0_message_handler: LSPS0MessageHandler<ES>,
config: LSPConfig,
provider_config: Option<LiquidityProviderConfig>,
}

impl<ES: Deref> LSPManager<ES>
impl<ES: Deref> LiquidityManager<ES>
where
ES::Target: EntropySource,
{
/// Constructor for the LSPManager
/// Constructor for the LiquidityManager
///
/// Sets up the required protocol message handlers based on the given [`LSPConfig`].
pub fn new(entropy_source: ES, config: LSPConfig) -> Self {
/// Sets up the required protocol message handlers based on the given [`LiquidityProviderConfig`].
pub fn new(entropy_source: ES, provider_config: Option<LiquidityProviderConfig>) -> Self {
let pending_messages = Arc::new(Mutex::new(vec![]));

let lsps0_message_handler =
Expand All @@ -70,7 +67,7 @@ where
pending_messages,
request_id_to_method_map: Mutex::new(HashMap::new()),
lsps0_message_handler,
config,
provider_config,
}
}

Expand All @@ -94,7 +91,7 @@ where
}
}

impl<ES: Deref> CustomMessageReader for LSPManager<ES>
impl<ES: Deref> CustomMessageReader for LiquidityManager<ES>
where
ES::Target: EntropySource,
{
Expand All @@ -110,7 +107,7 @@ where
}
}

impl<ES: Deref> CustomMessageHandler for LSPManager<ES>
impl<ES: Deref> CustomMessageHandler for LiquidityManager<ES>
where
ES::Target: EntropySource,
{
Expand Down Expand Up @@ -149,7 +146,7 @@ where
fn provided_node_features(&self) -> NodeFeatures {
let mut features = NodeFeatures::empty();

if self.config.is_lsp {
if self.provider_config.is_some() {
features.set_optional_custom_bit(LSPS_FEATURE_BIT).unwrap();
}

Expand All @@ -159,7 +156,7 @@ where
fn provided_init_features(&self, _their_node_id: &PublicKey) -> InitFeatures {
let mut features = InitFeatures::empty();

if self.config.is_lsp {
if self.provider_config.is_some() {
features.set_optional_custom_bit(LSPS_FEATURE_BIT).unwrap();
}

Expand Down

0 comments on commit f8eb772

Please sign in to comment.