Skip to content

Commit

Permalink
chore(rosenet-node): add logs for manual dialing
Browse files Browse the repository at this point in the history
  • Loading branch information
mkermani144 committed Oct 30, 2024
1 parent 7a9f962 commit b7b3d7c
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion packages/rosenet-node/lib/stream/stream-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,15 +111,33 @@ async function getRoseNetDirectStreamTo(to: string, node: Libp2p) {
[[], []] as [Multiaddr[], Multiaddr[]],
);

RoseNetNodeContext.logger.debug(
`Fetched and partitioned peer multiaddresses`,
{
publicAddresses: publicAddresses.map((address) => address.toString()),
otherAddresses: otherAddresses.map((address) => address.toString()),
},
);

if (publicAddresses) {
try {
return await node.dial(publicAddresses, {
const connection = await node.dial(publicAddresses, {
signal: AbortSignal.timeout(PUBLIC_MULTIADDR_DIAL_TIMEOUT),
});
RoseNetNodeContext.logger.debug(
`Public multiaddress dialed successfully`,
);
return connection;
} catch {
RoseNetNodeContext.logger.debug(
`Couldn't dial any public multiaddresses, trying relayed addresses`,
);
return await node.dial(otherAddresses);
}
} else {
RoseNetNodeContext.logger.debug(
'No public multiaddress found for this peer, trying relayed addresses',
);
return await node.dial(otherAddresses);
}
}));
Expand Down

0 comments on commit b7b3d7c

Please sign in to comment.