Skip to content

Conversation

@framicheli
Copy link
Contributor

No description provided.

Copy link
Contributor

@pool2win pool2win left a comment

Choose a reason for hiding this comment

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

Nice work! I left some comments which we will need to address though.

  • let's remove eyre as a dep
  • let's use config-rs for parsing config else we will end up writing a bunch of code to parse configs.

src/utils.rs Outdated
@@ -0,0 +1,13 @@
use std::path::PathBuf;
Copy link
Contributor

Choose a reason for hiding this comment

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

Missing and copyright identifier

src/utils.rs Outdated
@@ -0,0 +1,13 @@
use std::path::PathBuf;

Copy link
Contributor

Choose a reason for hiding this comment

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

We should read the bitcoin config from the TUI. In the wireframes we provide a screen to let user choose the config files. Were you planning to switch to it once we got that in place?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes I'll remove it in order to let the user select it

]
}

pub fn parse_config(path: &Path) -> Result<Vec<ConfigEntry>> {
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's add a bitcoin.conf.sample to the repo and add a unit test to read that config file and assert some of the config options. I think @R27-pixel 's other PR (pending review and merge) has CI support in now, so we can start building on it. I think you will need to setup the a non insta-rs based testing framework to test things.

Cargo.toml Outdated

[dependencies]
anyhow = "1.0.100"
color-eyre = "0.6.5"
Copy link
Contributor

Choose a reason for hiding this comment

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

Why this dependency? I think we already included anyhow and I wonder if we will create confusion adding a dependency of eyre?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In the ratatui docs it's used color_eyre

src/config.rs Outdated
@@ -0,0 +1,371 @@
use color_eyre::Result;
Copy link
Contributor

Choose a reason for hiding this comment

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

Missing license and copyright notices. See other files, we are using SPDX identifiers

@pool2win
Copy link
Contributor

@framicheli we need to rebase on to main. There's a bunch of conflicts we need to resolve.

Copy link
Contributor

@pool2win pool2win left a comment

Choose a reason for hiding this comment

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

Looking good but a few problems we need to address.

  1. Add comments to structs and functions. All of them.
  2. Add unit test to the config.rs module.
  3. Separate out all UI changes to a separate PR. This one should be limited to implement config.rs and testing it thoroughly. I can understand the temptation to run using the tui and see it working, but you can push it in a separate PR which comes after this PR. Otherwise it is too much to review and will result in an error during the review process.

@@ -1,24 +1,169 @@
// SPDX-FileCopyrightText: 2024 PDM Authors
//
Copy link
Contributor

Choose a reason for hiding this comment

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

Add comments for all structs and functions.

Comment on lines +98 to +107
let i = match self.list_state.selected() {
Some(i) => {
if i >= self.files.len() - 1 {
0
} else {
i + 1
}
}
None => 0,
};
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we can replace this condition with saturating_sub

Comment on lines +115 to +124
let i = match self.list_state.selected() {
Some(i) => {
if i == 0 {
self.files.len() - 1
} else {
i - 1
}
}
None => 0,
};
Copy link
Contributor

Choose a reason for hiding this comment

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

Replace with saturating_sub

}
}

pub fn load_config(&mut self, path: &str) -> Result<()> {
Copy link
Contributor

Choose a reason for hiding this comment

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

Add comment for all functions and structs

@@ -0,0 +1,448 @@
// SPDX-FileCopyrightText: 2024 PDM Authors
Copy link
Contributor

Choose a reason for hiding this comment

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

This module is doing a lot of heavy lifting, and is important to get right. We should add tests to this module to make sure we can parse a sample config file with default and non default values for all values.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants