Align terminology with specs

In specs, this is referenced as a `pubsubTopic`.
This commit is contained in:
Franck Royer 2021-05-13 16:29:44 +10:00
parent 6dbfa3e159
commit eb9955314c
No known key found for this signature in database
GPG Key ID: A82ED75A8DFC50A4
6 changed files with 17 additions and 16 deletions

View File

@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Enable passing `string`s to `addPeerToAddressBook`.
- Use `addPeerToAddressBook` in examples and usage doc.
- Settle on `js-waku` name across the board.
- **Breaking**: `RelayDefaultTopic` renamed to `DefaultPubsubTopic`.
## [0.1.0] - 2021-05-12

View File

@ -9,7 +9,7 @@ export const RelayCodec = '/vac/waku/relay/2.0.0-beta2';
/**
* RelayDefaultTopic is the default gossipsub topic to use for waku relay
*/
export const RelayDefaultTopic = '/waku/2/default-waku/proto';
export const DefaultPubsubTopic = '/waku/2/default-waku/proto';
/**
* RelayGossipFactor affects how many peers we will emit gossip to at each heartbeat.

View File

@ -12,7 +12,7 @@ import { delay } from '../delay';
import { Waku } from '../waku';
import { WakuMessage } from '../waku_message';
import { RelayCodec, RelayDefaultTopic } from './index';
import { DefaultPubsubTopic, RelayCodec } from './index';
const log = debug('waku:test');
@ -57,8 +57,8 @@ describe('Waku Relay', () => {
});
it('Subscribe', async function () {
const subscribers1 = waku1.libp2p.pubsub.getSubscribers(RelayDefaultTopic);
const subscribers2 = waku2.libp2p.pubsub.getSubscribers(RelayDefaultTopic);
const subscribers1 = waku1.libp2p.pubsub.getSubscribers(DefaultPubsubTopic);
const subscribers2 = waku2.libp2p.pubsub.getSubscribers(DefaultPubsubTopic);
expect(subscribers1).to.contain(waku2.libp2p.peerId.toB58String());
expect(subscribers2).to.contain(waku1.libp2p.peerId.toB58String());
@ -160,7 +160,7 @@ describe('Waku Relay', () => {
it('nim subscribes to js', async function () {
const nimPeerId = await nimWaku.getPeerId();
const subscribers = waku.libp2p.pubsub.getSubscribers(
RelayDefaultTopic
DefaultPubsubTopic
);
expect(subscribers).to.contain(nimPeerId.toB58String());
@ -244,7 +244,7 @@ describe('Waku Relay', () => {
while (subscribers.length === 0) {
await delay(200);
subscribers = waku.libp2p.pubsub.getSubscribers(RelayDefaultTopic);
subscribers = waku.libp2p.pubsub.getSubscribers(DefaultPubsubTopic);
}
const nimPeerId = await nimWaku.getPeerId();

View File

@ -19,11 +19,11 @@ import PeerId from 'peer-id';
import { WakuMessage } from '../waku_message';
import * as constants from './constants';
import { RelayCodec, RelayDefaultTopic } from './constants';
import { DefaultPubsubTopic, RelayCodec } from './constants';
import { getRelayPeers } from './get_relay_peers';
import { RelayHeartbeat } from './relay_heartbeat';
export { RelayCodec, RelayDefaultTopic };
export { RelayCodec, DefaultPubsubTopic };
/**
* See {GossipOptions} from libp2p-gossipsub
@ -94,7 +94,7 @@ export class WakuRelay extends Gossipsub implements Pubsub {
* @returns {void}
*/
public start(): void {
this.on(constants.RelayDefaultTopic, (event) => {
this.on(constants.DefaultPubsubTopic, (event) => {
const wakuMsg = WakuMessage.decode(event.data);
if (this.observers['']) {
this.observers[''].forEach((callbackFn) => {
@ -111,7 +111,7 @@ export class WakuRelay extends Gossipsub implements Pubsub {
});
super.start();
super.subscribe(constants.RelayDefaultTopic);
super.subscribe(constants.DefaultPubsubTopic);
}
/**
@ -122,7 +122,7 @@ export class WakuRelay extends Gossipsub implements Pubsub {
*/
public async send(message: WakuMessage): Promise<void> {
const msg = message.encode();
await super.publish(constants.RelayDefaultTopic, Buffer.from(msg));
await super.publish(constants.DefaultPubsubTopic, Buffer.from(msg));
}
/**

View File

@ -3,7 +3,7 @@ import { v4 as uuid } from 'uuid';
import * as proto from '../../proto/waku/v2/store';
import { DefaultContentTopic } from '../waku_message';
import { RelayDefaultTopic } from '../waku_relay';
import { DefaultPubsubTopic } from '../waku_relay';
export class HistoryRPC {
public constructor(public proto: proto.HistoryRPC) {}
@ -11,7 +11,7 @@ export class HistoryRPC {
static createQuery(
contentTopics: string[] = [DefaultContentTopic],
cursor?: proto.Index,
pubsubTopic: string = RelayDefaultTopic
pubsubTopic: string = DefaultPubsubTopic
): HistoryRPC {
const pagingInfo = {
pageSize: 10,

View File

@ -13,7 +13,7 @@ import { Multiaddr, multiaddr } from 'multiaddr';
import PeerId from 'peer-id';
import { WakuMessage } from '../lib/waku_message';
import { RelayDefaultTopic } from '../lib/waku_relay';
import { DefaultPubsubTopic } from '../lib/waku_relay';
import * as proto from '../proto/waku/v2/message';
import { existsAsync, mkdirAsync, openAsync } from './async_fs';
@ -167,7 +167,7 @@ export class NimWaku {
};
return this.rpcCall<boolean>('post_waku_v2_relay_v1_message', [
RelayDefaultTopic,
DefaultPubsubTopic,
rpcMessage,
]);
}
@ -176,7 +176,7 @@ export class NimWaku {
this.checkProcess();
return this.rpcCall<proto.WakuMessage[]>('get_waku_v2_relay_v1_messages', [
RelayDefaultTopic,
DefaultPubsubTopic,
]).then((msgs) => msgs.map((protoMsg) => new WakuMessage(protoMsg)));
}