mirror of
https://github.com/status-im/js-waku.git
synced 2025-02-22 09:58:10 +00:00
Simplify API
At this stage, if waku relay is mounted then we always want to subscribe to default topic. We can re-introduce the flexibility once we know what matters to the user. Resolves #17.
This commit is contained in:
parent
9a305033bc
commit
896462340a
@ -26,11 +26,6 @@ const ChatContentTopic = 'dingpu';
|
|||||||
console.log(`\t- ${address}`);
|
console.log(`\t- ${address}`);
|
||||||
});
|
});
|
||||||
|
|
||||||
// TODO: Automatically subscribe, tracked with
|
|
||||||
// https://github.com/status-im/js-waku/issues/17
|
|
||||||
await waku.relay.subscribe();
|
|
||||||
console.log('Subscribed to waku relay');
|
|
||||||
|
|
||||||
const rl = readline.createInterface({
|
const rl = readline.createInterface({
|
||||||
input: process.stdin,
|
input: process.stdin,
|
||||||
output: process.stdout,
|
output: process.stdout,
|
||||||
|
@ -34,9 +34,6 @@ describe('Waku Relay', () => {
|
|||||||
|
|
||||||
await waku1.dialWithMultiAddr(waku2.libp2p.peerId, waku2.libp2p.multiaddrs);
|
await waku1.dialWithMultiAddr(waku2.libp2p.peerId, waku2.libp2p.multiaddrs);
|
||||||
|
|
||||||
await waku1.relay.subscribe();
|
|
||||||
await waku2.relay.subscribe();
|
|
||||||
|
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
new Promise((resolve) =>
|
new Promise((resolve) =>
|
||||||
waku1.libp2p.pubsub.once('pubsub:subscription-change', () =>
|
waku1.libp2p.pubsub.once('pubsub:subscription-change', () =>
|
||||||
@ -107,7 +104,6 @@ describe('Waku Relay', () => {
|
|||||||
nimWaku = new NimWaku(makeLogFileName(this));
|
nimWaku = new NimWaku(makeLogFileName(this));
|
||||||
await nimWaku.start({ staticnode: multiAddrWithId });
|
await nimWaku.start({ staticnode: multiAddrWithId });
|
||||||
|
|
||||||
await waku.relay.subscribe();
|
|
||||||
await new Promise((resolve) =>
|
await new Promise((resolve) =>
|
||||||
waku.libp2p.pubsub.once('gossipsub:heartbeat', resolve)
|
waku.libp2p.pubsub.once('gossipsub:heartbeat', resolve)
|
||||||
);
|
);
|
||||||
@ -180,8 +176,6 @@ describe('Waku Relay', () => {
|
|||||||
nimWaku = new NimWaku(this.test?.ctx?.currentTest?.title + '');
|
nimWaku = new NimWaku(this.test?.ctx?.currentTest?.title + '');
|
||||||
await nimWaku.start();
|
await nimWaku.start();
|
||||||
|
|
||||||
await waku.relay.subscribe();
|
|
||||||
|
|
||||||
await waku.dial(await nimWaku.getMultiaddrWithId());
|
await waku.dial(await nimWaku.getMultiaddrWithId());
|
||||||
|
|
||||||
// Wait for identify protocol to finish
|
// Wait for identify protocol to finish
|
||||||
@ -276,8 +270,6 @@ describe('Waku Relay', () => {
|
|||||||
waku2.dial(nimWakuMultiaddr),
|
waku2.dial(nimWakuMultiaddr),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
await Promise.all([waku1.relay.subscribe(), waku2.relay.subscribe()]);
|
|
||||||
|
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
new Promise((resolve) =>
|
new Promise((resolve) =>
|
||||||
waku1.libp2p.pubsub.once('gossipsub:heartbeat', resolve)
|
waku1.libp2p.pubsub.once('gossipsub:heartbeat', resolve)
|
||||||
|
@ -294,11 +294,8 @@ export class WakuRelayPubsub extends Gossipsub {
|
|||||||
|
|
||||||
// This class provides an interface to execute the waku relay protocol
|
// This class provides an interface to execute the waku relay protocol
|
||||||
export class WakuRelay {
|
export class WakuRelay {
|
||||||
constructor(private pubsub: Pubsub) {}
|
constructor(private pubsub: Pubsub) {
|
||||||
|
this.pubsub.subscribe(constants.RelayDefaultTopic);
|
||||||
// At this stage we are always using the same topic so we do not pass it as a parameter
|
|
||||||
async subscribe() {
|
|
||||||
await this.pubsub.subscribe(constants.RelayDefaultTopic);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async publish(message: WakuMessage) {
|
async publish(message: WakuMessage) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user