This PR improves the network traffic graph widget in the Debug window to provide:
- Multiple time range options (from 5 minutes to 28 days)
- Data persistence between sessions
- Interactive visualization features including tooltips and logarithmic scaling
Motivation
The existing network traffic graph has limited utility with its fixed time range and lack of historical data preservation. This enhancement allows users to:
- Analyze network traffic patterns over different timeframes
- Preserve historical traffic data between session restarts
- Interact with the graph to get specific data points
- Better visualize varying traffic volumes with logarithmic scaling
These improvements are valuable for:
- Network debugging and troubleshooting
- Understanding Bitcoin Core’s network behaviour
- Monitoring traffic patterns for optimization
- Research purposes
Implementation
The implementation preserves all existing functionality while adding new features:
- Added a pre-configured timeframe selection (13 different timeframes)
- Implemented traffic data serialization and deserialization
- Enhanced the visualization with interactive features
- Improved tooltip information with precise timestamps and traffic rates
Supporting changes:
- Added formatBytesps function for a prettier display of traffic rates
- Added FormatISO8601Time for better time display
- Added setTotalBytes functionality to restore network statistics properly
Testing
Tested on Linux with various network conditions. The new functionality can be exercised by:
- Using the slider (or arrow keys) to select different time ranges
- Restarting the application to verify data persistence
- Clicking on the graph to toggle between linear and logarithmic scales
- Hovering over data points to view detailed information
Documentation
The changes are mostly self-documenting through the UI and are constrained to the Qt interface without affecting core functionality.
Compatibility
This PR maintains compatibility with existing functionality. The data persistence file uses proper serialization versioning to allow for future format changes if needed.