Skip to content

Add live P2Pool websocket integration for shares and peers#25

Open
R27-pixel wants to merge 4 commits into
p2poolv2:mainfrom
R27-pixel:share_info
Open

Add live P2Pool websocket integration for shares and peers#25
R27-pixel wants to merge 4 commits into
p2poolv2:mainfrom
R27-pixel:share_info

Conversation

@R27-pixel

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

Copy link
Copy Markdown
Contributor

Add websocket support for live pool updates(WIP)

  • Added websocket integration for live share and peer events
  • Moved websocket logic into a separate p2pool_websocket.rs
  • Integrated live updates into Pool Status
  • Added fallback support and p2pool client urls to config and localize tests
  • Fixed parsing for numeric/string bits
  • Improved shares table UI and live rendering
image

@codecov

codecov Bot commented May 12, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 89.57169% with 112 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/app.rs 20.00% 72 Missing ⚠️
src/components/p2pool_websocket.rs 95.97% 14 Missing ⚠️
src/main.rs 54.54% 10 Missing ⚠️
src/components/p2pool_client.rs 95.42% 8 Missing ⚠️
src/config.rs 61.90% 8 Missing ⚠️

📢 Thoughts on this report? Let us know!

@R27-pixel R27-pixel marked this pull request as draft May 12, 2026 21:33
@R27-pixel R27-pixel marked this pull request as ready for review July 3, 2026 17:55
@pool2win pool2win requested a review from Copilot July 3, 2026 19:06

Copilot AI left a comment

Copy link
Copy Markdown

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 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 P2PoolWebSocketClient for subscribing to live share/peer events and integrated it into App polling/state.
  • Extended the HTTP client/config to support base_url plus optional fallback_base_url, and added recent shares fetching + bits parsing 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.

Comment thread src/components/p2pool_client.rs Outdated
Comment thread src/components/p2pool_websocket.rs
Comment thread src/components/p2pool_websocket.rs
Comment thread src/components/p2pool_websocket.rs
Comment on lines +148 to +152
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);
}

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.

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.

Comment on lines +209 to +224
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()),
}
}

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.

maybe we can skip this, it’s just a small local helper, and the change would be cleanup rather than a functional fix.

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