libp2p-mesh 2026.5.31 → 2026.5.32
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/dist/src/mesh.js +9 -2
- package/package.json +1 -1
- package/src/mesh.ts +13 -4
package/dist/src/mesh.js
CHANGED
|
@@ -333,7 +333,9 @@ export function createMeshNetwork(options) {
|
|
|
333
333
|
runOnTransientConnection: true,
|
|
334
334
|
});
|
|
335
335
|
await state.node.start();
|
|
336
|
-
// Wait for DHT routing table to populate before registering pubkey
|
|
336
|
+
// Wait for DHT routing table to populate before registering pubkey.
|
|
337
|
+
// Non-blocking: we don't await the pubkey registration here — it runs
|
|
338
|
+
// in the background so the node can start serving messages immediately.
|
|
337
339
|
if (enableDHT) {
|
|
338
340
|
const dht = getDHTService();
|
|
339
341
|
if (dht) {
|
|
@@ -353,7 +355,12 @@ export function createMeshNetwork(options) {
|
|
|
353
355
|
logger?.warn?.(`[libp2p-mesh] DHT routing table still empty after ${maxAttempts}s; continuing anyway`);
|
|
354
356
|
}
|
|
355
357
|
if (state.instanceIdentity) {
|
|
356
|
-
|
|
358
|
+
// Fire-and-forget: pubkey registration is best-effort. In LAN
|
|
359
|
+
// scenarios with mDNS, peers connect directly and don't need DHT
|
|
360
|
+
// pubkey lookup to exchange identities. The registration will
|
|
361
|
+
// succeed once the DHT routing table populates (e.g. when a
|
|
362
|
+
// bootstrap peer is discovered or another DHT node joins).
|
|
363
|
+
registerPubkey(dht, state.instanceIdentity.id, state.instanceIdentity.pubkey, logger).catch(() => {
|
|
357
364
|
// Already logged inside registerPubkey
|
|
358
365
|
});
|
|
359
366
|
}
|
package/package.json
CHANGED
package/src/mesh.ts
CHANGED
|
@@ -388,7 +388,9 @@ export function createMeshNetwork(options: {
|
|
|
388
388
|
|
|
389
389
|
await state.node.start();
|
|
390
390
|
|
|
391
|
-
// Wait for DHT routing table to populate before registering pubkey
|
|
391
|
+
// Wait for DHT routing table to populate before registering pubkey.
|
|
392
|
+
// Non-blocking: we don't await the pubkey registration here — it runs
|
|
393
|
+
// in the background so the node can start serving messages immediately.
|
|
392
394
|
if (enableDHT) {
|
|
393
395
|
const dht = getDHTService();
|
|
394
396
|
if (dht) {
|
|
@@ -409,9 +411,16 @@ export function createMeshNetwork(options: {
|
|
|
409
411
|
}
|
|
410
412
|
|
|
411
413
|
if (state.instanceIdentity) {
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
414
|
+
// Fire-and-forget: pubkey registration is best-effort. In LAN
|
|
415
|
+
// scenarios with mDNS, peers connect directly and don't need DHT
|
|
416
|
+
// pubkey lookup to exchange identities. The registration will
|
|
417
|
+
// succeed once the DHT routing table populates (e.g. when a
|
|
418
|
+
// bootstrap peer is discovered or another DHT node joins).
|
|
419
|
+
registerPubkey(dht, state.instanceIdentity.id, state.instanceIdentity.pubkey, logger).catch(
|
|
420
|
+
() => {
|
|
421
|
+
// Already logged inside registerPubkey
|
|
422
|
+
},
|
|
423
|
+
);
|
|
415
424
|
}
|
|
416
425
|
}
|
|
417
426
|
}
|