Skip to content

Commit

Permalink
chore!: remove filter v1 (#1433)
Browse files Browse the repository at this point in the history
* rm: v1

* fix v2 imports

* remove tests for filter v1

* set filter v1 as default and rm v2 completely

* change import name for filter v2

* rename FilterV2 to Filter completely

* fix run check
  • Loading branch information
danisharora099 authored Jul 26, 2023
1 parent 92bb35a commit d483644
Show file tree
Hide file tree
Showing 16 changed files with 38 additions and 620 deletions.
2 changes: 0 additions & 2 deletions .cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,6 @@
"exponentiate",
"extip",
"fanout",
"Filterv1",
"Filterv2",
"floodsub",
"fontsource",
"globby",
Expand Down
2 changes: 1 addition & 1 deletion .size-limit.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ module.exports = [
{
name: "Light protocols",
path: "packages/core/bundle/index.js",
import: "{ wakuLightPush, wakuFilterV1, wakuFilterV2 }",
import: "{ wakuLightPush, wakuFilter }",
},
{
name: "History retrieval protocols",
Expand Down
7 changes: 2 additions & 5 deletions packages/core/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,8 @@ export * as message from "./lib/message/index.js";
export * as waku from "./lib/waku.js";
export { WakuNode, WakuOptions } from "./lib/waku.js";

export * as waku_filter_v1 from "./lib/filter/v1/index.js";
export { wakuFilter as wakuFilterV1 } from "./lib/filter/v1/index.js";

export * as waku_filter_v2 from "./lib/filter/v2/index.js";
export { wakuFilterV2 } from "./lib/filter/v2/index.js";
export * as waku_filter from "./lib/filter/index.js";
export { wakuFilter } from "./lib/filter/index.js";

export * as waku_light_push from "./lib/light_push/index.js";
export { wakuLightPush, LightPushCodec } from "./lib/light_push/index.js";
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import type {
IAsyncIterator,
IDecodedMessage,
IDecoder,
IFilterV2,
IFilter,
IProtoMessage,
IReceiver,
Libp2p,
Expand All @@ -25,8 +25,8 @@ import all from "it-all";
import * as lp from "it-length-prefixed";
import { pipe } from "it-pipe";

import { BaseProtocol } from "../../base_protocol.js";
import { DefaultPubSubTopic } from "../../constants.js";
import { BaseProtocol } from "../base_protocol.js";
import { DefaultPubSubTopic } from "../constants.js";

import {
FilterPushRpc,
Expand All @@ -41,7 +41,7 @@ type SubscriptionCallback<T extends IDecodedMessage> = {
callback: Callback<T>;
};

const FilterV2Codecs = {
const FilterCodecs = {
SUBSCRIBE: "/vac/waku/filter-subscribe/2.0.0-beta1",
PUSH: "/vac/waku/filter-push/2.0.0-beta1",
};
Expand Down Expand Up @@ -225,7 +225,7 @@ class Subscription {
}
}

class FilterV2 extends BaseProtocol implements IReceiver {
class Filter extends BaseProtocol implements IReceiver {
private readonly options: ProtocolCreateOptions;
private activeSubscriptions = new Map<string, Subscription>();

Expand All @@ -246,10 +246,10 @@ class FilterV2 extends BaseProtocol implements IReceiver {
}

constructor(libp2p: Libp2p, options?: ProtocolCreateOptions) {
super(FilterV2Codecs.SUBSCRIBE, libp2p.components);
super(FilterCodecs.SUBSCRIBE, libp2p.components);

libp2p.handle(FilterV2Codecs.PUSH, this.onRequest.bind(this)).catch((e) => {
log("Failed to register ", FilterV2Codecs.PUSH, e);
libp2p.handle(FilterCodecs.PUSH, this.onRequest.bind(this)).catch((e) => {
log("Failed to register ", FilterCodecs.PUSH, e);
});

this.activeSubscriptions = new Map();
Expand Down Expand Up @@ -365,10 +365,10 @@ class FilterV2 extends BaseProtocol implements IReceiver {
}
}

export function wakuFilterV2(
export function wakuFilter(
init: Partial<ProtocolCreateOptions> = {}
): (libp2p: Libp2p) => IFilterV2 {
return (libp2p: Libp2p) => new FilterV2(libp2p, init);
): (libp2p: Libp2p) => IFilter {
return (libp2p: Libp2p) => new Filter(libp2p, init);
}

async function pushMessage<T extends IDecodedMessage>(
Expand Down
53 changes: 0 additions & 53 deletions packages/core/src/lib/filter/v1/filter_rpc.ts

This file was deleted.

Loading

0 comments on commit d483644

Please sign in to comment.