Add chain_info in P2Pool Status#23
Conversation
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
There was a problem hiding this comment.
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
P2PoolClientandconfigmodule to fetch/chain_infowith 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.
| 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)); |
| reqwest = { version = "0.12", features = ["json", "rustls-tls", "blocking"] } | ||
| mockito = "1.7.2" | ||
| serde_json = "1.0.149" |
There was a problem hiding this comment.
Fixed!, moved to dev-dependencies.
| if self.current_screen == CurrentScreen::P2PoolStatus { | ||
| self.refresh_chain_info(); |
There was a problem hiding this comment.
Fixed!! moved chain_info fetching to an async task using tokio::spawn + channel, so it no longer blocks the UI thread.
| let mut app = App::new(); | ||
| app.settings = load_settings(); | ||
| bootstrap_from_settings(&mut app); | ||
| app.refresh_chain_info(); |
|
|
||
| pub fn load_api_config() -> Result<ApiConfig> { | ||
| let settings = Config::builder() | ||
| .add_source(File::with_name("config/config")) |
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
P2PoolClientto fetch/chain_infoAppand UIrefresh_chain_info()on P2Pool Status screenApp::new_with_client()for test injection (runtime unchanged)mockitoinstead of real network