Commit 4879de2
authored
feat(peers): updated ipfs-geoip and Peers screen optimizations (#2480)
* chore(deps): update ipfs-geoip to 9.3.0
* perf(peers): make geoip selectors synchronous, reduce re-renders
- 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
* feat(peers): enable geoip lookups for IPv6 peers
- 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)
* fix(peers): use HLRU for geoip memory cache to prevent unbounded growth
- peer-locations.js: swap `new Map()` for `HLRU(500)`, matching `failedAddrs` capacity
* perf(peers): progressive geoip rendering on initial load
- 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
* perf(peers): skip redundant re-renders when geoip data is unchanged
- 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)
* perf(peers): reduce unnecessary re-renders on peers page
- 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.
* fix(peers): wrap peers fallback in useMemo to fix CI build
react-hooks/exhaustive-deps flagged the `peerLocationsForSwarm || []`
expression as unstable dependency for the filteredPeerList useMemo.
CI treats warnings as errors, failing the build.1 parent bc3856b commit 4879de2
File tree
6 files changed
+304
-98
lines changed- src
- bundles
- peers
- PeersTable
- WorldMap
6 files changed
+304
-98
lines changedSome generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
64 | 64 | | |
65 | 65 | | |
66 | 66 | | |
67 | | - | |
| 67 | + | |
68 | 68 | | |
69 | 69 | | |
70 | 70 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
9 | | - | |
10 | 9 | | |
11 | 10 | | |
12 | 11 | | |
| |||
25 | 24 | | |
26 | 25 | | |
27 | 26 | | |
28 | | - | |
| 27 | + | |
29 | 28 | | |
30 | 29 | | |
31 | 30 | | |
| |||
44 | 43 | | |
45 | 44 | | |
46 | 45 | | |
47 | | - | |
48 | | - | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
49 | 108 | | |
50 | 109 | | |
51 | 110 | | |
| |||
66 | 125 | | |
67 | 126 | | |
68 | 127 | | |
69 | | - | |
70 | 128 | | |
71 | | - | |
| 129 | + | |
72 | 130 | | |
73 | 131 | | |
74 | 132 | | |
| |||
81 | 139 | | |
82 | 140 | | |
83 | 141 | | |
84 | | - | |
| 142 | + | |
85 | 143 | | |
86 | 144 | | |
87 | 145 | | |
| |||
107 | 165 | | |
108 | 166 | | |
109 | 167 | | |
110 | | - | |
| 168 | + | |
111 | 169 | | |
112 | 170 | | |
113 | 171 | | |
114 | 172 | | |
115 | 173 | | |
116 | 174 | | |
117 | | - | |
| 175 | + | |
118 | 176 | | |
119 | 177 | | |
120 | | - | |
121 | | - | |
| 178 | + | |
122 | 179 | | |
123 | 180 | | |
124 | 181 | | |
| |||
152 | 209 | | |
153 | 210 | | |
154 | 211 | | |
155 | | - | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
156 | 221 | | |
157 | 222 | | |
158 | 223 | | |
| |||
178 | 243 | | |
179 | 244 | | |
180 | 245 | | |
181 | | - | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
182 | 250 | | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
183 | 255 | | |
184 | 256 | | |
185 | 257 | | |
186 | 258 | | |
187 | 259 | | |
188 | 260 | | |
189 | | - | |
| 261 | + | |
| 262 | + | |
190 | 263 | | |
191 | 264 | | |
192 | | - | |
193 | | - | |
194 | | - | |
195 | | - | |
| 265 | + | |
196 | 266 | | |
197 | 267 | | |
198 | | - | |
| 268 | + | |
199 | 269 | | |
200 | | - | |
201 | | - | |
| 270 | + | |
| 271 | + | |
202 | 272 | | |
203 | 273 | | |
204 | 274 | | |
| |||
246 | 316 | | |
247 | 317 | | |
248 | 318 | | |
| 319 | + | |
249 | 320 | | |
250 | 321 | | |
| 322 | + | |
251 | 323 | | |
252 | 324 | | |
253 | 325 | | |
| |||
260 | 332 | | |
261 | 333 | | |
262 | 334 | | |
263 | | - | |
264 | | - | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
265 | 342 | | |
266 | 343 | | |
267 | 344 | | |
268 | | - | |
269 | | - | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
270 | 349 | | |
271 | 350 | | |
272 | 351 | | |
273 | | - | |
274 | | - | |
| 352 | + | |
| 353 | + | |
275 | 354 | | |
| 355 | + | |
276 | 356 | | |
277 | 357 | | |
278 | 358 | | |
279 | 359 | | |
280 | 360 | | |
281 | | - | |
| 361 | + | |
282 | 362 | | |
283 | 363 | | |
284 | 364 | | |
285 | | - | |
| 365 | + | |
286 | 366 | | |
287 | | - | |
288 | | - | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
289 | 370 | | |
290 | 371 | | |
291 | | - | |
| 372 | + | |
292 | 373 | | |
293 | | - | |
| 374 | + | |
294 | 375 | | |
295 | 376 | | |
296 | 377 | | |
| |||
0 commit comments