querysub 0.31.0 → 0.33.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.33.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,27 @@ async function runHeartbeatAuditLoop() {
292
295
  });
293
296
  }
294
297
 
298
+ // NOTE: Not just dead nodes, but also nodes that are unreachable, such as developer nodes.
299
+ let deadNodes = new Map<string, number>();
295
300
  async function fastMemorySync() {
296
- let checkNodes = shuffle(Array.from(allNodeIds2).filter(x => x !== getOurNodeId()), Date.now()).slice(0, API_AUDIT_COUNT);
301
+ let aliveNodes = new Set(Array.from(allNodeIds2).filter(x => x !== getOurNodeId()));
302
+ let deadThreshold = Date.now() - DEAD_NODE_POLL_COOLDOWN;
303
+ for (let [nodeId, time] of Array.from(deadNodes)) {
304
+ if (time < deadThreshold) {
305
+ deadNodes.delete(nodeId);
306
+ } else {
307
+ aliveNodes.delete(nodeId);
308
+ }
309
+ }
310
+ let checkNodes = shuffle(Array.from(aliveNodes), Date.now()).slice(0, API_AUDIT_COUNT);
297
311
  let otherNodesAll = await Promise.all(
298
- checkNodes.map(async nodeId =>
299
- await timeoutToUndefinedSilent(200, NodeDiscoveryController.nodes[nodeId].getAllNodeIds()) || []
300
- )
312
+ checkNodes.map(async nodeId => {
313
+ let nodes = await timeoutToUndefinedSilent(200, NodeDiscoveryController.nodes[nodeId].getAllNodeIds());
314
+ if (!nodes) {
315
+ deadNodes.set(nodeId, Date.now());
316
+ }
317
+ return nodes || [];
318
+ })
301
319
  );
302
320
  let otherNodes = Array.from(new Set(otherNodesAll.flat()));
303
321
  // This would log WAY too much, because we poll a lot, because we want to minimize downtime
package/src/config.ts CHANGED
@@ -54,5 +54,8 @@ export function authorityRaw() {
54
54
  }
55
55
 
56
56
  export function isPublic() {
57
+ if (!isNode()) {
58
+ return !location.hostname.startsWith("noproxy.");
59
+ }
57
60
  return !!yargObj.public;
58
61
  }