@hive-p2p/browser 1.0.98 → 1.0.102

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.
@@ -50,8 +50,8 @@ export class OfferQueue {
50
50
 
51
51
  export class Topologist {
52
52
  verbose; id; cryptoCodex; gossip; messager; peerStore; bootstraps; offersQueue = new OfferQueue();
53
- /** @type {Map<string, boolean>} */ bootstrapConnexionStates = new Map();
54
- /** @type {Set<string>} */ connectedBootstrapIds = new Set();
53
+ /** @type {Set<string>} */ connectedBootstraps = new Set();
54
+ /** @type {Set<string>} */ connectedBootstrapIds = new Set();
55
55
  /** @type {import('./node-services.mjs').NodeServices | undefined} */ services;
56
56
  /** @type {number} */ NEIGHBORS_TARGET;
57
57
  /** @type {number} */ HALF_TARGET;
@@ -132,7 +132,7 @@ export class Topologist {
132
132
  else if (connectingCount + nonPublicNeighborsCount > this.TWICE_TARGET) return; // no more bootstrap needed
133
133
 
134
134
  const publicUrl = this.bootstraps[this.nextBootstrapIndex++ % this.bootstraps.length];
135
- if (this.bootstrapConnexionStates.get(publicUrl)) return; // already connected/connecting
135
+ if (this.connectedBootstraps.has(publicUrl)) return; // already connected/connecting
136
136
  this.#connectToPublicNode(publicUrl);
137
137
  }
138
138
 
@@ -173,10 +173,10 @@ export class Topologist {
173
173
  const ws = new TRANSPORTS.WS_CLIENT(this.#getFullWsUrl(publicUrl)); ws.binaryType = 'arraybuffer';
174
174
  if (this.verbose > 1) ws.onerror = (error) => console.warn(`WebSocket error:`, error.stack);
175
175
  ws.onopen = () => {
176
- this.bootstrapConnexionStates.set(publicUrl, true);
176
+ this.connectedBootstraps.add(publicUrl);
177
177
  ws.onclose = () => {
178
- if (isAliasDetected) return;
179
- this.bootstrapConnexionStates.set(publicUrl, false);
178
+ this.connectedBootstraps.delete(publicUrl);
179
+ if (isAliasDetected) return; // early return (not totally connected, no peerStore record)
180
180
  this.connectedBootstrapIds.delete(remoteId);
181
181
  for (const cb of this.peerStore.callbacks.disconnect) cb(remoteId, 'out');
182
182
  }