mirror of https://github.com/status-im/js-waku.git
Get peer connection details from command line
This commit is contained in:
parent
c3cf6462cc
commit
b4e5d6d93c
|
@ -6,8 +6,9 @@ import readline from 'readline';
|
||||||
import { delay } from '../build/main/test_utils/delay';
|
import { delay } from '../build/main/test_utils/delay';
|
||||||
|
|
||||||
;(async function() {
|
;(async function() {
|
||||||
|
const opts = processArguments();
|
||||||
|
|
||||||
const waku = await Waku.create({listenAddresses: ['/ip4/0.0.0.0/tcp/55123']});
|
const waku = await Waku.create({ listenAddresses: ['/ip4/0.0.0.0/tcp/55123'] });
|
||||||
|
|
||||||
// TODO: Bubble event to waku, infere topic, decode msg
|
// TODO: Bubble event to waku, infere topic, decode msg
|
||||||
waku.libp2p.pubsub.on(TOPIC, event => {
|
waku.libp2p.pubsub.on(TOPIC, event => {
|
||||||
|
@ -16,17 +17,12 @@ import { delay } from '../build/main/test_utils/delay';
|
||||||
});
|
});
|
||||||
|
|
||||||
console.log('Waku started');
|
console.log('Waku started');
|
||||||
// Status static node
|
|
||||||
await waku.dial('/ip4/134.209.139.210/tcp/30303/p2p/16Uiu2HAmPLe7Mzm8TsYUubgCAW1aJoeFScxrLj8ppHFivPo97bUZ');
|
|
||||||
|
|
||||||
// Richard's node
|
|
||||||
// await waku.dial('/ip4/134.209.113.86/tcp/9000/p2p/16Uiu2HAmVVi6Q4j7MAKVibquW8aA27UNrA4Q8Wkz9EetGViu8ZF1');
|
|
||||||
|
|
||||||
// await waku.dial('/ip4/0.0.0.0/tcp/60000/p2p/16Uiu2HAmDVYacyxN4t1SYBhRSTDr6nmYwuY6qWWTgagZm558rFA6')
|
|
||||||
|
|
||||||
|
if (opts.staticNode) {
|
||||||
|
console.log(`dialing ${opts.staticNode}`);
|
||||||
|
await waku.dial(opts.staticNode);
|
||||||
await delay(100);
|
await delay(100);
|
||||||
|
}
|
||||||
console.log('Static node has been dialed');
|
|
||||||
|
|
||||||
await new Promise((resolve) =>
|
await new Promise((resolve) =>
|
||||||
waku.libp2p.pubsub.once('gossipsub:heartbeat', resolve)
|
waku.libp2p.pubsub.once('gossipsub:heartbeat', resolve)
|
||||||
|
@ -54,3 +50,26 @@ import { delay } from '../build/main/test_utils/delay';
|
||||||
});
|
});
|
||||||
|
|
||||||
})();
|
})();
|
||||||
|
|
||||||
|
interface Options {
|
||||||
|
staticNode?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
function processArguments(): Options {
|
||||||
|
let passedArgs = process.argv.slice(2);
|
||||||
|
|
||||||
|
let opts: Options = {};
|
||||||
|
|
||||||
|
while (passedArgs.length) {
|
||||||
|
const arg = passedArgs.shift();
|
||||||
|
switch (arg) {
|
||||||
|
case '--staticNode':
|
||||||
|
opts = Object.assign(opts, { staticNode: passedArgs.shift() });
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
console.log(`Argument ignored: ${arg}`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return opts;
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue