mirror of https://github.com/waku-org/js-waku.git
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.
This commit is contained in:
parent
13183350fa
commit
a5ff788eed
|
@ -7,6 +7,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||
|
||||
## [Unreleased]
|
||||
|
||||
### Added
|
||||
|
||||
- `multicodec` property from protocol interfaces.
|
||||
|
||||
### Removed
|
||||
|
||||
- Dependency on `@waku/peer-exchange`.
|
||||
|
||||
## [@waku/core@0.0.10] - 2023-01-25
|
||||
|
||||
### Changed
|
||||
|
|
|
@ -65,6 +65,7 @@ export type UnsubscribeFunction = () => Promise<void>;
|
|||
* - https://github.com/status-im/nwaku/issues/948
|
||||
*/
|
||||
class Filter implements IFilter {
|
||||
multicodec: string;
|
||||
pubSubTopic: string;
|
||||
private subscriptions: Map<string, Callback<any>>;
|
||||
private decoders: Map<
|
||||
|
@ -73,6 +74,7 @@ class Filter implements IFilter {
|
|||
>;
|
||||
|
||||
constructor(public components: FilterComponents, options?: CreateOptions) {
|
||||
this.multicodec = FilterCodec;
|
||||
this.subscriptions = new Map();
|
||||
this.decoders = new Map();
|
||||
this.pubSubTopic = options?.pubSubTopic ?? DefaultPubSubTopic;
|
||||
|
|
|
@ -52,9 +52,11 @@ export interface CreateOptions {
|
|||
* Implements the [Waku v2 Light Push protocol](https://rfc.vac.dev/spec/19/).
|
||||
*/
|
||||
class LightPush implements ILightPush {
|
||||
multicodec: string;
|
||||
pubSubTopic: string;
|
||||
|
||||
constructor(public components: LightPushComponents, options?: CreateOptions) {
|
||||
this.multicodec = LightPushCodec;
|
||||
this.pubSubTopic = options?.pubSubTopic ?? DefaultPubSubTopic;
|
||||
}
|
||||
|
||||
|
|
|
@ -105,9 +105,11 @@ export interface QueryOptions {
|
|||
* The Waku Store protocol can be used to retrieved historical messages.
|
||||
*/
|
||||
class Store implements IStore {
|
||||
multicodec: string;
|
||||
pubSubTopic: string;
|
||||
|
||||
constructor(public components: StoreComponents, options?: CreateOptions) {
|
||||
this.multicodec = StoreCodec;
|
||||
this.pubSubTopic = options?.pubSubTopic ?? DefaultPubSubTopic;
|
||||
}
|
||||
|
||||
|
|
|
@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||
|
||||
## [Unreleased]
|
||||
|
||||
### Added
|
||||
|
||||
- `multicodec` property on protocol interfaces.
|
||||
|
||||
## [0.0.7] - 2023-01-18
|
||||
|
||||
### Added
|
||||
|
|
|
@ -12,6 +12,7 @@ export enum Protocols {
|
|||
}
|
||||
|
||||
export interface PointToPointProtocol {
|
||||
multicodec: string;
|
||||
peerStore: PeerStore;
|
||||
peers: () => Promise<Peer[]>;
|
||||
}
|
||||
|
|
|
@ -30,6 +30,7 @@ const log = debug("waku:peer-exchange");
|
|||
* Implementation of the Peer Exchange protocol (https://rfc.vac.dev/spec/34/)
|
||||
*/
|
||||
export class WakuPeerExchange implements IPeerExchange {
|
||||
multicodec: string;
|
||||
private callback:
|
||||
| ((response: PeerExchangeResponse) => Promise<void>)
|
||||
| undefined;
|
||||
|
@ -42,6 +43,7 @@ export class WakuPeerExchange implements IPeerExchange {
|
|||
public components: PeerExchangeComponents,
|
||||
public createOptions?: ProtocolOptions
|
||||
) {
|
||||
this.multicodec = PeerExchangeCodec;
|
||||
this.components.registrar
|
||||
.handle(PeerExchangeCodec, this.handler.bind(this))
|
||||
.catch((e) => log("Failed to register peer exchange protocol", e));
|
||||
|
|
Loading…
Reference in New Issue