pruneStaleNodes method
Removes nodes that haven't been seen within threshold.
Call this periodically from the background service.
Implementation
Future<int> pruneStaleNodes(Duration threshold) {
final cutoff =
DateTime.now().subtract(threshold).millisecondsSinceEpoch;
return (delete(nodes)..where((t) => t.lastSeen.isSmallerThanValue(cutoff)))
.go();
}