Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: calculation of node uptimes by looking at
recentUptime
(#414)
* Update workers.go to handle nil pointers * handle errors from db and update breaking changes * Update monitorworkers and refactor code * Fix sendWork nill pointer * update AccumulatedUptime calculation Fix accumulated uptime calculation in NodeData This commit addresses issues in the accumulated uptime calculation for nodes in the network. Previously, the calculation could lead to inflated uptime values due to repeated additions of time since the last known activity markers, regardless of the node's actual activity status. The updated logic now accurately calculates the uptime based on the node's activity periods, ensuring that only the duration of actual activity is added to the accumulated uptime. For nodes that have left the network, the uptime is calculated as the difference between the last left and last joined timestamps. For active nodes, the uptime since the first join is considered, preventing overestimation. This change ensures a more accurate representation of node uptime, enhancing the reliability of network monitoring metrics. - Add precise calculation for nodes that have left the network - Implement dynamic uptime update for active nodes - Prevent repeated addition of the same uptime duration - Ensure accurate tracking of node activity periods * Update node uptime calculation and event tracking The calculation methods for current uptime and accumulated uptime have been commented out and their calls removed from the join and leave event methods. Instead, they are replaced with an update method called when a node leaves. Additionally, before processing an expired connect event, the node is now forced to leave to ensure correct timestamp updating. * Update nodeData with new data The previous version of the code attempted to persist a wrong instance into the `nodeData` map. The update corrects this issue by ensuring that `nodeData` is updated with the new instance `nd`, which contains all recent modifications. * Remove IsActive attribute from NodeEventTracker The IsActive attribute in the NodeEventTracker has been removed because it should not be set by other nodes. It should only be manipulated by the join/leave events tracked by this node. --------- Co-authored-by: Ettore Di Giacinto <[email protected]> Co-authored-by: Bob Stevens <[email protected]> Co-authored-by: John Dutchak <[email protected]>
- Loading branch information