basic functionality
This commit is contained in:
21
src/NodeInfo.cpp
Normal file
21
src/NodeInfo.cpp
Normal file
@@ -0,0 +1,21 @@
|
||||
#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 diff = now - node.lastSeen;
|
||||
if (diff < NODE_INACTIVE_THRESHOLD) {
|
||||
node.status = NodeInfo::ACTIVE;
|
||||
} else if (diff < NODE_INACTIVE_THRESHOLD) {
|
||||
node.status = NodeInfo::INACTIVE;
|
||||
} else {
|
||||
node.status = NodeInfo::DEAD;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user