27 lines
860 B
C++
27 lines
860 B
C++
#include "NodeInfo.h"
|
|
|
|
const char* statusToStr(NodeInfo::Status status) {
|
|
switch (status) {
|
|
case NodeInfo::ACTIVE: return "active";
|
|
case NodeInfo::INACTIVE: return "inactive";
|
|
case NodeInfo::DEAD: return "dead";
|
|
default: return "unknown";
|
|
}
|
|
}
|
|
|
|
void updateNodeStatus(NodeInfo &node, unsigned long now, unsigned long inactive_threshold, unsigned long dead_threshold) {
|
|
unsigned long diff = now - node.lastSeen;
|
|
if (diff < inactive_threshold) {
|
|
node.status = NodeInfo::ACTIVE;
|
|
} else if (diff < dead_threshold) {
|
|
node.status = NodeInfo::DEAD;
|
|
} else {
|
|
node.status = NodeInfo::DEAD;
|
|
}
|
|
}
|
|
|
|
void updateNodeStatus(NodeInfo &node, unsigned long now) {
|
|
// Legacy implementation using hardcoded values
|
|
updateNodeStatus(node, now, NODE_INACTIVE_THRESHOLD, NODE_DEAD_THRESHOLD);
|
|
}
|