pruneStaleNodes method

Future<int> pruneStaleNodes(
  1. Duration threshold
)

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();
}