Implemented the Bitcoin Core Logs feature in the existing Bitcoin Status Logs tab. - #28
Implemented the Bitcoin Core Logs feature in the existing Bitcoin Status Logs tab.#28R27-pixel wants to merge 14 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 implements a functional Bitcoin Core Logs viewer inside the existing Bitcoin Status “Logs” tab, including persisted configuration for locating debug.log, background polling/refresh, filtering + scrolling interactions, and accompanying UI snapshot/test updates. It also introduces a Bitcoin Core RPC client to populate “Chain Info” and “Peers” tabs based on the configured bitcoin.conf.
Changes:
- Added Bitcoin Core log path resolution + recent-line snapshot reading, wired into
Apppolling/refresh and the Bitcoin Status UI. - Persisted new settings for Bitcoin Core data directory and explicit log file path, and updated settings UI/status bar behavior + snapshots accordingly.
- Added a Bitcoin Core RPC client and UI rendering for Chain Info + Peers, plus expanded/updated test coverage across modules.
Reviewed changes
Copilot reviewed 17 out of 17 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| src/app.rs | Adds Bitcoin chain/log state, background polling, refresh logic, and OSC52 copy support. |
| src/bitcoin_logs.rs | New module for resolving debug.log paths and reading recent log lines/snapshots. |
| src/components/bitcoin_client.rs | New Bitcoin Core JSON-RPC client used to fetch chain info and peer info. |
| src/components/bitcoin_status_view.rs | Replaces placeholder tabs with real Chain Info / Logs / Peers rendering and log input handling. |
| src/components/mod.rs | Exposes the new bitcoin_client module. |
| src/components/p2pool_status_view.rs | Deduplicates live share rows to avoid repeated entries. |
| src/components/settings_view.rs | Adds two new settings fields and updates rendering logic/tests. |
| src/components/status_bar.rs | Adds Bitcoin Logs tab key-hint behavior and adjusts settings-field indexing. |
| src/lib.rs | Exports the new bitcoin_logs module. |
| src/main.rs | Integrates Bitcoin polling/refresh into the main loop and updates explorer handling for new triggers. |
| src/p2poolv2_config.rs | Adds additional branch-coverage tests for dispatch_edit. |
| src/settings.rs | Adds persisted settings fields + tests for Bitcoin Core log/data-dir paths. |
| src/ui.rs | Updates UI snapshot test setup for the logs tab initial state. |
| src/snapshots/pdm__ui__tests__settings_screen_render.snap | Snapshot update for new settings fields. |
| src/snapshots/pdm__ui__tests__bitcoin_status_tab_peers_render.snap | Snapshot update for peers tab rendering prompt. |
| src/snapshots/pdm__ui__tests__bitcoin_status_tab_logs_render.snap | Snapshot update for new logs viewer UI and key hints. |
| src/snapshots/pdm__ui__tests__bitcoin_status_screen_render.snap | Snapshot update for chain info tab rendering prompt. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| pub fn copy_filtered_bitcoin_logs(&mut self) { | ||
| let text = self.filtered_bitcoin_log_lines().join("\n"); | ||
| if text.is_empty() { | ||
| self.bitcoin_log_status = "No Bitcoin Core log lines to copy.".to_string(); | ||
| return; | ||
| } | ||
|
|
| fn default_data_dir() -> Option<PathBuf> { | ||
| std::env::var_os("HOME").map(|home| PathBuf::from(home).join(".bitcoin")) | ||
| } |
| let mut position = file_len; | ||
| let mut newline_count = 0usize; | ||
| let mut chunks: Vec<Vec<u8>> = Vec::new(); | ||
|
|
||
| while position > 0 && newline_count <= max_lines { | ||
| let read_size = READ_CHUNK_SIZE.min(position); | ||
| position -= read_size; | ||
|
|
||
| file.seek(SeekFrom::Start(position)) | ||
| .with_context(|| format!("could not seek {}", path.display()))?; | ||
|
|
||
| let mut chunk = vec![0u8; read_size as usize]; | ||
| file.read_exact(&mut chunk) | ||
| .with_context(|| format!("could not read {}", path.display()))?; | ||
|
|
||
| newline_count += chunk.iter().filter(|byte| **byte == b'\n').count(); | ||
| chunks.push(chunk); | ||
| } |
DRAFT PR