helia-coord 1.2.5 → 1.2.7

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.
@@ -33,12 +33,11 @@ class ThisNodeUseCases {
33
33
  this.circuitRelayInfo = localConfig.circuitRelayInfo
34
34
 
35
35
  // Initialize v1 relay list. Allows user to overwrite with local config.
36
- this.v1Relays = []
37
36
  if (localConfig.v1Relays) {
38
37
  this.v1Relays = localConfig.v1Relays
39
38
  // console.log('v1Relays: ', this.v1Relays)
40
39
  }
41
- // console.log('this-node-use-cases.js v1Relays: ', this.v1Relays)
40
+ console.log('this-node-use-cases.js v1Relays: ', this.v1Relays)
42
41
 
43
42
  // Bind 'this' object to all subfunctions
44
43
  this.updateUseCases = this.updateUseCases.bind(this)
@@ -242,8 +241,8 @@ class ThisNodeUseCases {
242
241
  // - If peer is advertised as a circuit relay, try to connect directly through
243
242
  // the advertised Circuit Relay IP address and port.
244
243
  // - Attempt to connect to peer directly through its advertised multiaddrs.
245
- // - Connect to peer through v2 Circuit Relays (built into ipfs-service-provider)
246
244
  // - Connect to peer through v1 Circuit Relays (standalone v1 Circuit Relay)
245
+ // - Connect to peer through v2 Circuit Relays (built into ipfs-service-provider)
247
246
  async refreshPeerConnections () {
248
247
  try {
249
248
  // console.log('this.thisNode: ', this.thisNode)
@@ -324,7 +323,7 @@ class ThisNodeUseCases {
324
323
  // Try a direct connection with the peer by going through
325
324
  // the multiaddrs in the announcement object.
326
325
  const filteredMultiaddrs = this.utils.filterMultiaddrs(peerData.data.ipfsMultiaddrs)
327
- console.log('filteredMultiaddrs: ', filteredMultiaddrs)
326
+ // console.log('filteredMultiaddrs: ', filteredMultiaddrs)
328
327
 
329
328
  for (let j = 0; j < filteredMultiaddrs.length; j++) {
330
329
  const multiaddr = filteredMultiaddrs[j]
@@ -348,6 +347,39 @@ class ThisNodeUseCases {
348
347
  break
349
348
  }
350
349
  }
350
+
351
+ if (connected) {
352
+ continue
353
+ }
354
+
355
+ // If we could not connect to the node through the v2 Circuit Relays,
356
+ // try connecting to it through the v1 Circuit Relays.
357
+ for (let j = 0; j < this.v1Relays.length; j++) {
358
+ const thisV1Relay = this.v1Relays[j]
359
+
360
+ // Generate a multiaddr for connecting to the peer through a circuit relay.
361
+ const multiaddr = `${thisV1Relay}/p2p-circuit/p2p/${thisPeer}`
362
+
363
+ console.log(`refreshPeerConnections() connecting to peer through V1 Circuit Relay with this multiaddr: ${multiaddr}`)
364
+ this.adapters.log.statusLog(2, `refreshPeerConnections() connecting to peer through V1 Circuit Relay with this multiaddr: ${multiaddr}`)
365
+
366
+ // Attempt to connect to the node through a circuit relay.
367
+ connected = await this.adapters.ipfs.connectToPeer({ multiaddr })
368
+
369
+ if (connected) {
370
+ this.adapters.log.statusLog(2,
371
+ `Successfully connected to peer ${thisPeer} through v1 circuit relay ${thisV1Relay}.`
372
+ )
373
+
374
+ // Add the connection multiaddr to the peer, so that we can see
375
+ // exactly how we're connected to the peer.
376
+ const thisPeerData = this.thisNode.peerData.filter(x => x.from === thisPeer)
377
+ thisPeerData[0].data.connectionAddr = multiaddr
378
+
379
+ break
380
+ }
381
+ }
382
+
351
383
  if (connected) {
352
384
  continue
353
385
  }
@@ -392,36 +424,6 @@ class ThisNodeUseCases {
392
424
  }
393
425
  }
394
426
  }
395
-
396
- // If we could not connect to the node through the v2 Circuit Relays,
397
- // try connecting to it through the v1 Circuit Relays.
398
- if (!connected) {
399
- for (let j = 0; j < this.v1Relays.length; j++) {
400
- const thisV1Relay = this.v1Relays[j]
401
-
402
- // Generate a multiaddr for connecting to the peer through a circuit relay.
403
- const multiaddr = `${thisV1Relay.multiaddr}/p2p-circuit/p2p/${thisPeer}`
404
-
405
- console.log(`refreshPeerConnections() connecting to peer through V1 Circuit Relay with this multiaddr: ${multiaddr}`)
406
- this.adapters.log.statusLog(2, `refreshPeerConnections() connecting to peer through V1 Circuit Relay with this multiaddr: ${multiaddr}`)
407
-
408
- // Attempt to connect to the node through a circuit relay.
409
- connected = await this.adapters.ipfs.connectToPeer({ multiaddr })
410
-
411
- if (connected) {
412
- this.adapters.log.statusLog(2,
413
- `Successfully connected to peer ${thisPeer} through v1 circuit relay ${thisV1Relay.multiaddr}.`
414
- )
415
-
416
- // Add the connection multiaddr to the peer, so that we can see
417
- // exactly how we're connected to the peer.
418
- const thisPeerData = this.thisNode.peerData.filter(x => x.from === thisPeer)
419
- thisPeerData[0].data.connectionAddr = multiaddr
420
-
421
- break
422
- }
423
- }
424
- }
425
427
  }
426
428
 
427
429
  const now = new Date()
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "helia-coord",
3
- "version": "1.2.5",
3
+ "version": "1.2.7",
4
4
  "description": "A JS library for helping IPFS peers coordinate, find a common interest, and stay connected around that interest.",
5
5
  "main": "./index.js",
6
6
  "type": "module",