mirror of https://github.com/status-im/js-waku.git
Enable dialing several nodes
This commit is contained in:
parent
35fcb4d880
commit
c6ce32dc54
|
@ -49,10 +49,12 @@ export default async function startChat(): Promise<void> {
|
||||||
[ChatContentTopic]
|
[ChatContentTopic]
|
||||||
);
|
);
|
||||||
|
|
||||||
if (opts.staticNode) {
|
await Promise.all(
|
||||||
console.log(`Dialing ${opts.staticNode}`);
|
opts.staticNodes.map((addr) => {
|
||||||
await waku.dial(opts.staticNode);
|
console.log(`Dialing ${addr}`);
|
||||||
}
|
return waku.dial(addr);
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
// If we connect to a peer with WakuStore, we run the protocol
|
// If we connect to a peer with WakuStore, we run the protocol
|
||||||
// TODO: Instead of doing it `once` it should always be done but
|
// TODO: Instead of doing it `once` it should always be done but
|
||||||
|
@ -89,22 +91,20 @@ export default async function startChat(): Promise<void> {
|
||||||
}
|
}
|
||||||
|
|
||||||
interface Options {
|
interface Options {
|
||||||
staticNode?: Multiaddr;
|
staticNodes: Multiaddr[];
|
||||||
listenAddr: string;
|
listenAddr: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
function processArguments(): Options {
|
function processArguments(): Options {
|
||||||
const passedArgs = process.argv.slice(2);
|
const passedArgs = process.argv.slice(2);
|
||||||
|
|
||||||
let opts: Options = { listenAddr: '/ip4/0.0.0.0/tcp/0' };
|
let opts: Options = { listenAddr: '/ip4/0.0.0.0/tcp/0', staticNodes: [] };
|
||||||
|
|
||||||
while (passedArgs.length) {
|
while (passedArgs.length) {
|
||||||
const arg = passedArgs.shift();
|
const arg = passedArgs.shift();
|
||||||
switch (arg) {
|
switch (arg) {
|
||||||
case '--staticNode':
|
case '--staticNode':
|
||||||
opts = Object.assign(opts, {
|
opts.staticNodes.push(multiaddr(passedArgs.shift()!));
|
||||||
staticNode: multiaddr(passedArgs.shift()!),
|
|
||||||
});
|
|
||||||
break;
|
break;
|
||||||
case '--listenAddr':
|
case '--listenAddr':
|
||||||
opts = Object.assign(opts, { listenAddr: passedArgs.shift() });
|
opts = Object.assign(opts, { listenAddr: passedArgs.shift() });
|
||||||
|
|
Loading…
Reference in New Issue