Skip to content

Commit 8d0e647

Browse files
feat!: filter v2 (#1332)
* implement proto * implement filter v2 * add tests * minor improvements - make unsubscribe functions private in filter - enable all tests * enable all tests * readd multiaddrinput * address comment removals * unsubscribe based on contentFilters passed * update unsubscribe function parameters in test * reset interfaces & filter v1 * refactor filterv2 into 2 classes - removes generics from types on filter which means manual typecasting to filter version is required on consumer side - defaults to filterv2 - splits filterv2 into 2 classes: - one to create the subscription object with a peer which returns the second class - the other to manage all subscription functions * updates filter tests for the new API - also fixes an interface import * update `toAsyncIterator` test for Filter V1 * implement IReceiver on FilterV2 * remove return values from subscription functions * update `to_async_iterator` * address variable naming * add tsdoc comments for hidden function * address minor comments * update docs to default to filter v2 * address comments * rename `wakuFilter` to `wakuFilterV1` * chore: Remove static variables (#1371) * chore: Remove static variables - Remove internal types from `@core/interfaces` - Remove data being redundantly stored (pubsub topic) - Remove usage of static variables - Clean up callbacks and decoders when using `unsubscribe` - Clean up callbacks and decoders when using `unsubscribeAll` * fix setting activeSubscription --------- Co-authored-by: danisharora099 <danisharora099@gmail.com> * make activeSub getter and setter private * update size-limit --------- Co-authored-by: fryorcraken.eth <110212804+fryorcraken@users.noreply.github.com>
1 parent 6870c9e commit 8d0e647

24 files changed

+1615
-106
lines changed

.cspell.json

+2
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@
3939
"exponentiate",
4040
"extip",
4141
"fanout",
42+
"Filterv1",
43+
"Filterv2",
4244
"floodsub",
4345
"fontsource",
4446
"globby",

.size-limit.cjs

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ module.exports = [
3636
{
3737
name: "Light protocols",
3838
path: "packages/core/bundle/index.js",
39-
import: "{ wakuLightPush, wakuFilter }",
39+
import: "{ wakuLightPush, wakuFilterV1, wakuFilterV2 }",
4040
},
4141
{
4242
name: "History retrieval protocols",

package-lock.json

+57-57
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/core/src/index.ts

+5-2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,11 @@ export * as message from "./lib/message/index.js";
1111
export * as waku from "./lib/waku.js";
1212
export { WakuNode, WakuOptions } from "./lib/waku.js";
1313

14-
export * as waku_filter from "./lib/filter/index.js";
15-
export { wakuFilter } from "./lib/filter/index.js";
14+
export * as waku_filter_v1 from "./lib/filter/v1/index.js";
15+
export { wakuFilter as wakuFilterV1 } from "./lib/filter/v1/index.js";
16+
17+
export * as waku_filter_v2 from "./lib/filter/v2/index.js";
18+
export { wakuFilterV2 } from "./lib/filter/v2/index.js";
1619

1720
export * as waku_light_push from "./lib/light_push/index.js";
1821
export { wakuLightPush, LightPushCodec } from "./lib/light_push/index.js";

packages/core/src/lib/filter/filter_rpc.ts packages/core/src/lib/filter/v1/filter_rpc.ts

+1-4
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
1+
import { ContentFilter } from "@waku/interfaces";
12
import { proto_filter as proto } from "@waku/proto";
23
import { v4 as uuid } from "uuid";
34

4-
export type ContentFilter = {
5-
contentTopic: string;
6-
};
7-
85
/**
96
* FilterRPC represents a message conforming to the Waku Filter protocol
107
*/

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

+5-6
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import type { IncomingStreamData } from "@libp2p/interface-registrar";
44
import type {
55
ActiveSubscriptions,
66
Callback,
7+
ContentFilter,
78
IAsyncIterator,
89
IDecodedMessage,
910
IDecoder,
@@ -19,13 +20,11 @@ import all from "it-all";
1920
import * as lp from "it-length-prefixed";
2021
import { pipe } from "it-pipe";
2122

22-
import { BaseProtocol } from "../base_protocol.js";
23-
import { DefaultPubSubTopic } from "../constants.js";
24-
import { toProtoMessage } from "../to_proto_message.js";
23+
import { BaseProtocol } from "../../base_protocol.js";
24+
import { DefaultPubSubTopic } from "../../constants.js";
25+
import { toProtoMessage } from "../../to_proto_message.js";
2526

26-
import { ContentFilter, FilterRpc } from "./filter_rpc.js";
27-
28-
export { ContentFilter };
27+
import { FilterRpc } from "./filter_rpc.js";
2928

3029
export const FilterCodec = "/vac/waku/filter/2.0.0-beta1";
3130

0 commit comments

Comments
 (0)