Add live P2Pool websocket integration for shares and peers#25
Add live P2Pool websocket integration for shares and peers#25R27-pixel wants to merge 4 commits into
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 P2Pool status updates by introducing a websocket client for share/peer events, wiring it into the app’s event loop/state, and expanding the P2Pool Status UI with a new “Shares” tab and live-rendered tables.
Changes:
- Added
P2PoolWebSocketClientfor subscribing to live share/peer events and integrated it intoApppolling/state. - Extended the HTTP client/config to support
base_urlplus optionalfallback_base_url, and added recent shares fetching +bitsparsing for string/number. - Updated the P2Pool Status UI to include a Shares tab with formatted difficulty/timestamps and live peer event display.
Reviewed changes
Copilot reviewed 14 out of 15 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| src/snapshots/pdm__ui__tests__p2pool_status_screen_render.snap | Updated UI snapshot to reflect new Shares tab label. |
| src/p2poolv2_config.rs | Minor test helper cleanup (inline config load). |
| src/main.rs | Polls share info + live websocket events; small idiomatic refactors. |
| src/config.rs | Adds ApiConfig defaults and supports base_url + fallback_base_url. |
| src/components/p2pool_websocket.rs | New websocket client, event types, subscription logic, and tests. |
| src/components/p2pool_status_view.rs | Adds Shares tab/table rendering and live peer event/error display + tests. |
| src/components/p2pool_config_view.rs | Small refactors and test setup adjustments. |
| src/components/p2pool_client.rs | Adds shares API types, numeric/string bits parsing, and fallback logic + tests. |
| src/components/mod.rs | Exposes new p2pool_websocket module. |
| src/components/file_explorer.rs | Test assertion updated for filtering behavior. |
| src/app.rs | Stores share/live state and spawns HTTP + websocket tasks when opening P2Pool Status. |
| dummy.toml | Removes previously-committed dummy config file. |
| config/config.toml | Adds api.base_url and commented fallback_base_url example. |
| Cargo.toml | Adds websocket + URL + JSON dependencies. |
| Cargo.lock | Locks new dependency graph entries. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| fn apply_auth(&self, url: &mut Url) { | ||
| if let Some((user, pass)) = &self.auth_credentials { | ||
| let token = STANDARD.encode(format!("{}:{}", user, pass)); | ||
| url.query_pairs_mut().append_pair("token", &token); | ||
| } |
There was a problem hiding this comment.
I verified the p2poolv2_api crate, and the /ws endpoint currently authenticates only via the ?token= query parameter. Supporting Authorization headers would require a backend change, so I'm keeping the current implementation for compatibility.
| fn deserialize_string_or_number<'de, D>(deserializer: D) -> Result<String, D::Error> | ||
| where | ||
| D: Deserializer<'de>, | ||
| { | ||
| #[derive(Deserialize)] | ||
| #[serde(untagged)] | ||
| enum StringOrNumber { | ||
| String(String), | ||
| Number(u64), | ||
| } | ||
|
|
||
| match StringOrNumber::deserialize(deserializer)? { | ||
| StringOrNumber::String(value) => Ok(value), | ||
| StringOrNumber::Number(value) => Ok(value.to_string()), | ||
| } | ||
| } |
There was a problem hiding this comment.
maybe we can skip this, it’s just a small local helper, and the change would be cleanup rather than a functional fix.
Add websocket support for live pool updates(WIP)
p2pool_websocket.rsbits