Skip to content

feat(peers): updated ipfs-geoip and Peers screen optimizations#2480

Open
lidel wants to merge 10 commits intomainfrom
chore/update-ipfs-geoip
Open

feat(peers): updated ipfs-geoip and Peers screen optimizations#2480
lidel wants to merge 10 commits intomainfrom
chore/update-ipfs-geoip

Conversation

@lidel
Copy link
Member

@lidel lidel commented Feb 27, 2026

- peer-locations.js: replace p-memoize getPublicIP with sync ref-cached version,
  make isPrivateAndNearby/selectPeerLocationsForSwarm/selectPeersCoordinates sync,
  add in-memory cache to PeerLocationResolver to skip IndexedDB reads,
  bump poll interval from 1s to 3s, add queue.onIdle() re-fetch trigger
- PeersTable.js: remove useState/useEffect async wrapper, consume array directly
- WorldMap.js: remove async wrappers from MapPins and PeerInfo,
  fix resize useEffect missing dependency array
- peer-locations.test.js: remove unnecessary await from sync selector calls
- peer-locations.js: replace `isNonHomeIPv4` with `isPublicIP` to accept
  both protocol 4 (IPv4) and 41 (IPv6), using `ip.isPrivate()` to skip
  all private/loopback/link-local addresses for both families
- peer-locations.js: rename `ipv4Tuple`/`ipv4Addr` to `ipTuple`/`ipAddr`
  since the filter now matches both IP versions
- peer-locations.test.js: add tests for IPv6 peer location resolution,
  private IPv6/IPv4 `isPrivate` flag, and private IP filtering in
  `findLocations`
- peer-locations.test.js: fix `optimizedPeerSet` IP generation to use
  only public addresses (old pattern produced 10.x and 127.x)
- peer-locations.js: swap `new Map()` for `HLRU(500)`, matching `failedAddrs` capacity
- guard getPromise against null peers to prevent crash during ramp-up
- chain immediate re-fetches during optimizedPeerSet ramp-up (10→100→200→all)
  instead of waiting 3s staleAfter between each pass
- replace onIdle handler with throttled completed event listener so
  uncached geoip lookups render progressively as they land
- guard null peers with quick 100ms retry instead of waiting 3s staleAfter
- shallow-compare new locations with previous data and return the same
  reference when unchanged, preventing the full selector/render cascade
  (selectPeerLocationsForSwarm → selectPeersCoordinates → MapPins D3 rebuild)
- WorldMap: use useRef for selectedTimeout instead of useState
  every mouse leave was calling setSelectedTimeout which re-rendered
  WorldMap, recreated handleMapPinMouseEnter (selectedTimeout in deps),
  passed new prop to MapPins, triggering full D3 SVG rebuild.
  timeout ID is bookkeeping, not display state -- useRef avoids renders.
- WorldMap: memoize GeoPath d3 projection with useMemo([width, height])
  every mouse hover changed selectedPeers, re-rendered WorldMap,
  re-rendered GeoPath which created a new d3.geoPath() reference,
  passed as new prop to MapPins triggering SVG rebuild. now stable
  unless window is resized.
- peer-locations: remove unused selectBootstrapPeers from
  selectPeerLocationsForSwarm. reselect recomputed the selector
  (mapping all 298 peers) whenever bootstrap peers changed, even
  though bootstrapPeers was never referenced in the function body.
@lidel lidel mentioned this pull request Feb 27, 2026
5 tasks
react-hooks/exhaustive-deps flagged the `peerLocationsForSwarm || []`
expression as unstable dependency for the filteredPeerList useMemo.
CI treats warnings as errors, failing the build.
@lidel lidel marked this pull request as ready for review February 28, 2026 00:26
@lidel lidel requested a review from a team as a code owner February 28, 2026 00:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant