@highway1/cli 0.1.31 → 0.1.33
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 +16 -4
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/commands/join.ts +12 -2
package/dist/index.js
CHANGED
|
@@ -116169,10 +116169,11 @@ async function createNode(config2) {
|
|
|
116169
116169
|
bootstrapPeers = [],
|
|
116170
116170
|
enableDHT = true,
|
|
116171
116171
|
enableRelay = false,
|
|
116172
|
+
reserveRelaySlot = false,
|
|
116172
116173
|
enableMDNS = false,
|
|
116173
116174
|
privateKey
|
|
116174
116175
|
} = config2;
|
|
116175
|
-
const relayListenAddrs = [];
|
|
116176
|
+
const relayListenAddrs = reserveRelaySlot ? bootstrapPeers.map((peer) => `${peer}/p2p-circuit`) : [];
|
|
116176
116177
|
const libp2pConfig = {
|
|
116177
116178
|
addresses: {
|
|
116178
116179
|
listen: [...listenAddresses, ...relayListenAddrs]
|
|
@@ -116222,7 +116223,10 @@ async function createNode(config2) {
|
|
|
116222
116223
|
}
|
|
116223
116224
|
if (peerDiscovery.length > 0) libp2pConfig.peerDiscovery = peerDiscovery;
|
|
116224
116225
|
const libp2p = await createLibp2p(libp2pConfig);
|
|
116225
|
-
logger2.info("Libp2p node created"
|
|
116226
|
+
logger2.info("Libp2p node created", {
|
|
116227
|
+
listenAddresses: libp2pConfig.addresses.listen,
|
|
116228
|
+
reserveRelaySlot
|
|
116229
|
+
});
|
|
116226
116230
|
return {
|
|
116227
116231
|
libp2p,
|
|
116228
116232
|
start: async () => {
|
|
@@ -116230,7 +116234,8 @@ async function createNode(config2) {
|
|
|
116230
116234
|
logger2.info("Node started", {
|
|
116231
116235
|
peerId: libp2p.peerId.toString(),
|
|
116232
116236
|
addresses: libp2p.getMultiaddrs().map((ma) => ma.toString()),
|
|
116233
|
-
relay: enableRelay
|
|
116237
|
+
relay: enableRelay,
|
|
116238
|
+
reserveRelaySlot
|
|
116234
116239
|
});
|
|
116235
116240
|
},
|
|
116236
116241
|
stop: async () => {
|
|
@@ -118284,10 +118289,15 @@ function registerJoinCommand(program2) {
|
|
|
118284
118289
|
});
|
|
118285
118290
|
const hasRelayAddr = () => node.getMultiaddrs().some((a2) => a2.includes("/p2p-circuit"));
|
|
118286
118291
|
if (!hasRelayAddr()) {
|
|
118292
|
+
info("Waiting for relay reservation...");
|
|
118287
118293
|
await new Promise((resolve) => {
|
|
118288
|
-
const timeout = setTimeout(
|
|
118294
|
+
const timeout = setTimeout(() => {
|
|
118295
|
+
info(`Relay reservation timeout after 5s. Multiaddrs: ${node.getMultiaddrs().join(", ")}`);
|
|
118296
|
+
resolve();
|
|
118297
|
+
}, 5e3);
|
|
118289
118298
|
const check = () => {
|
|
118290
118299
|
if (hasRelayAddr()) {
|
|
118300
|
+
info(`Relay address acquired: ${node.getMultiaddrs().filter((a2) => a2.includes("/p2p-circuit")).join(", ")}`);
|
|
118291
118301
|
clearTimeout(timeout);
|
|
118292
118302
|
resolve();
|
|
118293
118303
|
}
|
|
@@ -118295,6 +118305,8 @@ function registerJoinCommand(program2) {
|
|
|
118295
118305
|
node.libp2p.addEventListener("self:peer:update", check);
|
|
118296
118306
|
setTimeout(() => node.libp2p.removeEventListener("self:peer:update", check), 5e3);
|
|
118297
118307
|
});
|
|
118308
|
+
} else {
|
|
118309
|
+
info(`Relay address already present: ${node.getMultiaddrs().filter((a2) => a2.includes("/p2p-circuit")).join(", ")}`);
|
|
118298
118310
|
}
|
|
118299
118311
|
connectSpin.succeed("Connected to network!");
|
|
118300
118312
|
const cardSpin = spinner("Publishing Agent Card to DHT...");
|