Skip to content

Add chain_info in P2Pool Status#23

Open
R27-pixel wants to merge 3 commits into
p2poolv2:mainfrom
R27-pixel:chain_info
Open

Add chain_info in P2Pool Status#23
R27-pixel wants to merge 3 commits into
p2poolv2:mainfrom
R27-pixel:chain_info

Conversation

@R27-pixel
Copy link
Copy Markdown
Contributor

@R27-pixel R27-pixel commented May 2, 2026

Add chain_info in P2Pool Status

Displays live chain_info from the P2Pool API in the P2Pool Status screen, with error handling when the node is unavailable

  • Added P2PoolClient to fetch /chain_info
  • Integrated chain info + error handling into App and UI
  • Added refresh_chain_info() on P2Pool Status screen
  • Introduced App::new_with_client() for test injection (runtime unchanged)
  • Updated UI test to use mockito instead of real network
  • Added client unit tests
image

@codecov
Copy link
Copy Markdown

codecov Bot commented May 2, 2026

Codecov Report

❌ Patch coverage is 86.08696% with 32 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/app.rs 57.14% 15 Missing ⚠️
src/components/p2pool_status_view.rs 67.56% 12 Missing ⚠️
src/components/p2pool_client.rs 97.60% 3 Missing ⚠️
src/main.rs 0.00% 2 Missing ⚠️

📢 Thoughts on this report? Let us know!

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds live chain_info retrieval for the P2Pool Status screen by introducing a blocking HTTP client, wiring the fetched state into App, and updating the TUI plus tests to render the returned chain data.

Changes:

  • Added a new P2PoolClient and config module to fetch /chain_info with optional basic auth.
  • Extended App/startup flow to fetch and cache chain info, then render it in the P2Pool Status view.
  • Updated UI snapshots and added mocked tests for the new P2Pool status content.

Reviewed changes

Copilot reviewed 11 out of 12 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
src/ui.rs Updates the P2Pool status screen test to use a mocked /chain_info response.
src/snapshots/pdm__ui__tests__p2pool_status_screen_render.snap Refreshes the snapshot to match the new P2Pool status UI layout/content.
src/main.rs Triggers chain info refresh during startup before entering the event loop.
src/lib.rs Re-exports the new config module from the library crate.
src/config.rs Adds API config loading for host/port/basic-auth credentials.
src/components/p2pool_status_view.rs Replaces placeholder status content with tabbed chain info rendering and error/loading states.
src/components/p2pool_client.rs Introduces the blocking HTTP client, response model, auth support, and unit tests.
src/components/mod.rs Exposes the new p2pool_client component module.
src/app.rs Stores P2Pool client/state and refreshes chain info when navigating to the status screen.
config/config.toml Adds a repo-local API config file with host/port/auth defaults.
Cargo.toml Adds HTTP/mocking/JSON dependencies needed for the new client and tests.
Cargo.lock Locks the newly added dependency graph.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/components/p2pool_client.rs Outdated
Comment on lines +36 to +41
let (base_url, auth_credentials) = load_api_config()
.map(|cfg| {
let credentials = cfg.auth_user.zip(cfg.auth_pass);
(cfg.base_url, credentials)
})
.unwrap_or_else(|_| ("http://localhost:8332".to_string(), None));
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed!!

Comment thread Cargo.toml Outdated
Comment on lines +20 to +22
reqwest = { version = "0.12", features = ["json", "rustls-tls", "blocking"] }
mockito = "1.7.2"
serde_json = "1.0.149"
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed!, moved to dev-dependencies.

Comment thread src/app.rs Outdated
Comment on lines +179 to +180
if self.current_screen == CurrentScreen::P2PoolStatus {
self.refresh_chain_info();
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed!! moved chain_info fetching to an async task using tokio::spawn + channel, so it no longer blocks the UI thread.

Comment thread src/main.rs Outdated
let mut app = App::new();
app.settings = load_settings();
bootstrap_from_settings(&mut app);
app.refresh_chain_info();
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Removed!!

Comment thread src/config.rs Outdated

pub fn load_api_config() -> Result<ApiConfig> {
let settings = Config::builder()
.add_source(File::with_name("config/config"))
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed!!

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.

2 participants