querysub 0.31.0 → 0.32.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "querysub",
3
- "version": "0.31.0",
3
+ "version": "0.32.0",
4
4
  "main": "index.js",
5
5
  "license": "MIT",
6
6
  "note1": "note on node-forge fork, see https://github.com/digitalbazaar/forge/issues/744 for details",
@@ -49,6 +49,9 @@ let DISK_AUDIT_RATE = timeInMinute * 5;
49
49
  let API_AUDIT_RATE = timeInSecond;
50
50
  let API_AUDIT_COUNT = 12;
51
51
 
52
+
53
+ let DEAD_NODE_POLL_COOLDOWN = timeInMinute * 5;
54
+
52
55
  let shutdown = false;
53
56
 
54
57
  const archives = lazy(() => getArchives("nodes/"));
@@ -292,12 +295,26 @@ async function runHeartbeatAuditLoop() {
292
295
  });
293
296
  }
294
297
 
298
+ let deadNodes = new Map<string, number>();
295
299
  async function fastMemorySync() {
296
- let checkNodes = shuffle(Array.from(allNodeIds2).filter(x => x !== getOurNodeId()), Date.now()).slice(0, API_AUDIT_COUNT);
300
+ let aliveNodes = new Set(Array.from(allNodeIds2).filter(x => x !== getOurNodeId()));
301
+ let deadThreshold = Date.now() - DEAD_NODE_POLL_COOLDOWN;
302
+ for (let [nodeId, time] of Array.from(deadNodes)) {
303
+ if (time < deadThreshold) {
304
+ deadNodes.delete(nodeId);
305
+ } else {
306
+ aliveNodes.delete(nodeId);
307
+ }
308
+ }
309
+ let checkNodes = shuffle(Array.from(aliveNodes), Date.now()).slice(0, API_AUDIT_COUNT);
297
310
  let otherNodesAll = await Promise.all(
298
- checkNodes.map(async nodeId =>
299
- await timeoutToUndefinedSilent(200, NodeDiscoveryController.nodes[nodeId].getAllNodeIds()) || []
300
- )
311
+ checkNodes.map(async nodeId => {
312
+ let nodes = await timeoutToUndefinedSilent(200, NodeDiscoveryController.nodes[nodeId].getAllNodeIds());
313
+ if (!nodes) {
314
+ deadNodes.set(nodeId, Date.now());
315
+ }
316
+ return nodes || [];
317
+ })
301
318
  );
302
319
  let otherNodes = Array.from(new Set(otherNodesAll.flat()));
303
320
  // This would log WAY too much, because we poll a lot, because we want to minimize downtime