Skip to content

Commit

Permalink
feat(getinfo) : adds alias inside lampo.conf
Browse files Browse the repository at this point in the history
  • Loading branch information
Harshit933 committed Apr 5, 2024
1 parent 5bc56d7 commit d748484
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lampo-common/src/conf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ pub struct LampoConf {
pub channels_keys: Option<String>,
pub log_file: Option<String>,
pub log_level: String,
pub alias: Option<String>,
}

impl LampoConf {
Expand Down Expand Up @@ -48,6 +49,7 @@ impl LampoConf {
channels_keys: None,
log_level: "info".to_string(),
log_file: None,
alias: None,
}
}

Expand Down Expand Up @@ -213,6 +215,8 @@ impl TryFrom<String> for LampoConf {
_ => "info".to_string(),
};
let log_file = conf.get_conf("log-file").unwrap_or_else(|_| None);
let alias = conf.get_conf("alias").unwrap_or(None);

Ok(Self {
inner: Some(conf),
root_path,
Expand All @@ -227,6 +231,7 @@ impl TryFrom<String> for LampoConf {
channels_keys,
log_file,
log_level: level,
alias,
})
}
}
Expand Down
1 change: 1 addition & 0 deletions lampo-common/src/model/getinfo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ pub struct GetInfo {
pub peers: usize,
pub channels: usize,
pub chain: String,
pub alias: String,
}
9 changes: 9 additions & 0 deletions lampod/src/ln/inventory_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,20 @@ impl InventoryHandler for LampoInventoryManager {
match event {
InventoryCommand::GetNodeInfo(chan) => {
let chain = self.channel_manager.conf.network.to_string();
let alias = self
.channel_manager
.conf
.alias
.as_ref()
.map(|alias| alias.to_string());
// we have to put "" in case of alias missing as cln provide us with a random alias.
let alias = alias.unwrap_or_else(|| "".to_string());
let getinfo = GetInfo {
node_id: self.channel_manager.manager().get_our_node_id().to_string(),
peers: self.peer_manager.manager().list_peers().len(),
channels: self.channel_manager.manager().list_channels().len(),
chain,
alias,
};
let getinfo = json::to_value(getinfo)?;
chan.send(getinfo)?;
Expand Down

0 comments on commit d748484

Please sign in to comment.