Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enhance Hashrate Calculation Logic with Sliding Window Approach Description: This commit introduces a refined Hashrate calculation mechanism to provide more accurate real-time metrics for the Kaspa mining pool. The changes involve implementing a sliding window approach to track and calculate Hashrate based on the most recent set of shares, thereby addressing potential inaccuracies caused by long-term averaging. Changes: Update WorkerStats Structure: Added a recentShares array to the WorkerStats interface to store the timestamp and difficulty of each share found by a miner. Refine addShare Method: Modified the addShare function in SharesManager to record each share's timestamp and difficulty in the recentShares array. Introduced logic to filter out old shares that fall outside the defined sliding window (10 minutes). Implement Sliding Window Hashrate Calculation: Updated the calcHashRates method to compute the Hashrate using only the shares within the sliding window. Calculated the average difficulty over the relevant shares and the time difference from the first share in the window to determine the Hashrate. Updated the Prometheus metrics (minerHashRateGauge and poolHashRateGauge) with the new Hashrate values. Ensure Prometheus Compatibility: Integrated the refined Hashrate calculation seamlessly with existing Prometheus metrics, allowing for accurate real-time Hashrate reporting and long-term trend analysis. Benefits: Provides more accurate and responsive Hashrate measurements. Enhances real-time monitoring capabilities, better reflecting the miners' current performance. Prepares the system for long-term trend analysis through Prometheus, leveraging accurate real-time data. Testing: Ensure that the changes have been tested in a development environment. Monitor Hashrate metrics post-deployment to validate the improvements.
- Loading branch information