@@ -6,17 +6,17 @@ import {
6
6
} from "@chainsafe/libp2p-gossipsub" ;
7
7
import type { PeerIdStr , TopicStr } from "@chainsafe/libp2p-gossipsub/types" ;
8
8
import { SignaturePolicy } from "@chainsafe/libp2p-gossipsub/types" ;
9
- import { CustomEvent } from "@libp2p/interfaces/events" ;
10
9
import type {
10
+ ActiveSubscriptions ,
11
11
Callback ,
12
+ IDecodedMessage ,
12
13
IDecoder ,
13
14
IEncoder ,
14
15
IMessage ,
15
16
IRelay ,
16
17
ProtocolCreateOptions ,
17
18
SendResult ,
18
19
} from "@waku/interfaces" ;
19
- import { IDecodedMessage } from "@waku/interfaces" ;
20
20
import debug from "debug" ;
21
21
22
22
import { DefaultPubSubTopic } from "../constants.js" ;
@@ -36,10 +36,6 @@ export type Observer<T extends IDecodedMessage> = {
36
36
export type RelayCreateOptions = ProtocolCreateOptions & GossipsubOpts ;
37
37
export type ContentTopic = string ;
38
38
39
- type BasicEventPayload = {
40
- contentTopic : string ;
41
- } ;
42
-
43
39
/**
44
40
* Implements the [Waku v2 Relay protocol](https://rfc.vac.dev/spec/11/).
45
41
* Must be passed as a `pubsub` module to a `Libp2p` instance.
@@ -120,30 +116,20 @@ class Relay extends GossipSub implements IRelay {
120
116
121
117
pushOrInitMapSet ( this . observers , contentTopic , observer ) ;
122
118
123
- this . dispatchEvent (
124
- new CustomEvent < BasicEventPayload > ( "observer:added" , {
125
- detail : {
126
- contentTopic,
127
- } ,
128
- } )
129
- ) ;
130
-
131
119
return ( ) => {
132
120
const observers = this . observers . get ( contentTopic ) ;
133
121
if ( observers ) {
134
122
observers . delete ( observer ) ;
135
-
136
- this . dispatchEvent (
137
- new CustomEvent < BasicEventPayload > ( "observer:removed" , {
138
- detail : {
139
- contentTopic,
140
- } ,
141
- } )
142
- ) ;
143
123
}
144
124
} ;
145
125
}
146
126
127
+ public getActiveSubscriptions ( ) : ActiveSubscriptions {
128
+ const map = new Map ( ) ;
129
+ map . set ( this . pubSubTopic , this . observers . keys ( ) ) ;
130
+ return map ;
131
+ }
132
+
147
133
private async processIncomingMessage < T extends IDecodedMessage > (
148
134
pubSubTopic : string ,
149
135
bytes : Uint8Array
0 commit comments