@highway1/cli 0.1.33 → 0.1.34
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/index.js +18 -6
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/commands/join.ts +26 -7
package/dist/index.js
CHANGED
|
@@ -118292,18 +118292,30 @@ function registerJoinCommand(program2) {
|
|
|
118292
118292
|
info("Waiting for relay reservation...");
|
|
118293
118293
|
await new Promise((resolve) => {
|
|
118294
118294
|
const timeout = setTimeout(() => {
|
|
118295
|
-
info(`Relay reservation timeout after
|
|
118295
|
+
info(`Relay reservation timeout after 10s. Multiaddrs: ${node.getMultiaddrs().join(", ")}`);
|
|
118296
118296
|
resolve();
|
|
118297
|
-
},
|
|
118298
|
-
const
|
|
118297
|
+
}, 1e4);
|
|
118298
|
+
const onReservation = () => {
|
|
118299
|
+
info(`Relay reservation successful!`);
|
|
118300
|
+
clearTimeout(timeout);
|
|
118301
|
+
setTimeout(() => {
|
|
118302
|
+
info(`Relay addresses: ${node.getMultiaddrs().filter((a2) => a2.includes("/p2p-circuit")).join(", ")}`);
|
|
118303
|
+
resolve();
|
|
118304
|
+
}, 500);
|
|
118305
|
+
};
|
|
118306
|
+
const onPeerUpdate = () => {
|
|
118299
118307
|
if (hasRelayAddr()) {
|
|
118300
|
-
info(`Relay address acquired
|
|
118308
|
+
info(`Relay address acquired via peer update`);
|
|
118301
118309
|
clearTimeout(timeout);
|
|
118302
118310
|
resolve();
|
|
118303
118311
|
}
|
|
118304
118312
|
};
|
|
118305
|
-
node.libp2p.addEventListener("
|
|
118306
|
-
|
|
118313
|
+
node.libp2p.addEventListener("relay:reservation", onReservation, { once: true });
|
|
118314
|
+
node.libp2p.addEventListener("self:peer:update", onPeerUpdate);
|
|
118315
|
+
setTimeout(() => {
|
|
118316
|
+
node.libp2p.removeEventListener("relay:reservation", onReservation);
|
|
118317
|
+
node.libp2p.removeEventListener("self:peer:update", onPeerUpdate);
|
|
118318
|
+
}, 1e4);
|
|
118307
118319
|
});
|
|
118308
118320
|
} else {
|
|
118309
118321
|
info(`Relay address already present: ${node.getMultiaddrs().filter((a2) => a2.includes("/p2p-circuit")).join(", ")}`);
|