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