Skip to content

Commit a5ff788

Browse files
committed
feat: codec as a property of the protocol implementations
For easy access from `@waku/core` without the need to depend on package implementing the protocol.
1 parent 1318335 commit a5ff788

File tree

7 files changed

+21
-0
lines changed

7 files changed

+21
-0
lines changed

packages/core/CHANGELOG.md

+8
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
### Added
11+
12+
- `multicodec` property from protocol interfaces.
13+
14+
### Removed
15+
16+
- Dependency on `@waku/peer-exchange`.
17+
1018
## [@waku/core@0.0.10] - 2023-01-25
1119

1220
### Changed

packages/core/src/lib/filter/index.ts

+2
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ export type UnsubscribeFunction = () => Promise<void>;
6565
* - https://github.com/status-im/nwaku/issues/948
6666
*/
6767
class Filter implements IFilter {
68+
multicodec: string;
6869
pubSubTopic: string;
6970
private subscriptions: Map<string, Callback<any>>;
7071
private decoders: Map<
@@ -73,6 +74,7 @@ class Filter implements IFilter {
7374
>;
7475

7576
constructor(public components: FilterComponents, options?: CreateOptions) {
77+
this.multicodec = FilterCodec;
7678
this.subscriptions = new Map();
7779
this.decoders = new Map();
7880
this.pubSubTopic = options?.pubSubTopic ?? DefaultPubSubTopic;

packages/core/src/lib/light_push/index.ts

+2
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,11 @@ export interface CreateOptions {
5252
* Implements the [Waku v2 Light Push protocol](https://rfc.vac.dev/spec/19/).
5353
*/
5454
class LightPush implements ILightPush {
55+
multicodec: string;
5556
pubSubTopic: string;
5657

5758
constructor(public components: LightPushComponents, options?: CreateOptions) {
59+
this.multicodec = LightPushCodec;
5860
this.pubSubTopic = options?.pubSubTopic ?? DefaultPubSubTopic;
5961
}
6062

packages/core/src/lib/store/index.ts

+2
Original file line numberDiff line numberDiff line change
@@ -105,9 +105,11 @@ export interface QueryOptions {
105105
* The Waku Store protocol can be used to retrieved historical messages.
106106
*/
107107
class Store implements IStore {
108+
multicodec: string;
108109
pubSubTopic: string;
109110

110111
constructor(public components: StoreComponents, options?: CreateOptions) {
112+
this.multicodec = StoreCodec;
111113
this.pubSubTopic = options?.pubSubTopic ?? DefaultPubSubTopic;
112114
}
113115

packages/interfaces/CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
### Added
11+
12+
- `multicodec` property on protocol interfaces.
13+
1014
## [0.0.7] - 2023-01-18
1115

1216
### Added

packages/interfaces/src/protocols.ts

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ export enum Protocols {
1212
}
1313

1414
export interface PointToPointProtocol {
15+
multicodec: string;
1516
peerStore: PeerStore;
1617
peers: () => Promise<Peer[]>;
1718
}

packages/peer-exchange/src/waku_peer_exchange.ts

+2
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ const log = debug("waku:peer-exchange");
3030
* Implementation of the Peer Exchange protocol (https://rfc.vac.dev/spec/34/)
3131
*/
3232
export class WakuPeerExchange implements IPeerExchange {
33+
multicodec: string;
3334
private callback:
3435
| ((response: PeerExchangeResponse) => Promise<void>)
3536
| undefined;
@@ -42,6 +43,7 @@ export class WakuPeerExchange implements IPeerExchange {
4243
public components: PeerExchangeComponents,
4344
public createOptions?: ProtocolOptions
4445
) {
46+
this.multicodec = PeerExchangeCodec;
4547
this.components.registrar
4648
.handle(PeerExchangeCodec, this.handler.bind(this))
4749
.catch((e) => log("Failed to register peer exchange protocol", e));

0 commit comments

Comments
 (0)