Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve getinfo #203

Merged
merged 4 commits into from
Apr 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we need to announce this, but looks like I still need to finish some work here #202

Lets open a issue and keep track of this

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't get it. Why do we need to announce alias? Is this related to bolt12?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't get it. Why do we need to announce alias? Is this related to bolt12?

we need to announce to the network with a node announcement, it is not related to bolt12, but I did some of the work on the PR that support the bolt12


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
3 changes: 3 additions & 0 deletions lampo-common/src/model/getinfo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,7 @@ pub struct GetInfo {
pub peers: usize,
pub channels: usize,
pub chain: String,
pub alias: String,
pub blockheight: u32,
pub lampo_dir: String,
}
2 changes: 1 addition & 1 deletion lampod/src/ln/channel_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,14 +75,14 @@ pub type LampoRouter = DefaultRouter<

pub struct LampoChannelManager {
monitor: Option<Arc<LampoChainMonitor>>,
onchain: Arc<LampoChainManager>,
wallet_manager: Arc<dyn WalletManager>,
persister: Arc<LampoPersistence>,
graph: Option<Arc<LampoGraph>>,
score: Option<Arc<Mutex<LampoScorer>>>,
handler: RefCell<Option<Arc<LampoHandler>>>,
router: Option<Arc<LampoRouter>>,

pub(crate) onchain: Arc<LampoChainManager>,
pub(crate) conf: LampoConf,
pub(crate) channeld: Option<Arc<LampoChannel>>,
pub(crate) logger: Arc<LampoLogger>,
Expand Down
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.clone();
// we have to put "" in case of alias missing as cln provide us with a random alias.
let alias = alias.unwrap_or_default();
let (_, height) = self.channel_manager.onchain.backend.get_best_block()?;
let blockheight = height.unwrap_or_default();
let lampo_dir = self.channel_manager.conf.root_path.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,
blockheight,
lampo_dir,
};
let getinfo = json::to_value(getinfo)?;
chan.send(getinfo)?;
Expand Down
Loading