@@ -2,9 +2,9 @@ import type { PeerId, Stream } from "@libp2p/interface";
22import type { IncomingStreamData } from "@libp2p/interface-internal" ;
33import {
44 type ContentTopic ,
5- type CoreProtocolResult ,
5+ type FilterCoreResult ,
6+ FilterError ,
67 type Libp2p ,
7- ProtocolError ,
88 type PubsubTopic
99} from "@waku/interfaces" ;
1010import { WakuMessage } from "@waku/proto" ;
@@ -62,7 +62,7 @@ export class FilterCore {
6262 pubsubTopic : PubsubTopic ,
6363 peerId : PeerId ,
6464 contentTopics : ContentTopic [ ]
65- ) : Promise < CoreProtocolResult > {
65+ ) : Promise < FilterCoreResult > {
6666 const stream = await this . streamManager . getStream ( peerId ) ;
6767
6868 const request = FilterSubscribeRpc . createSubscribeRequest (
@@ -88,7 +88,7 @@ export class FilterCore {
8888 return {
8989 success : null ,
9090 failure : {
91- error : ProtocolError . GENERIC_FAIL ,
91+ error : FilterError . SUBSCRIPTION_FAILED ,
9292 peerId : peerId
9393 }
9494 } ;
@@ -103,8 +103,11 @@ export class FilterCore {
103103 ) ;
104104 return {
105105 failure : {
106- error : ProtocolError . REMOTE_PEER_REJECTED ,
107- peerId : peerId
106+ error : FilterError . REMOTE_PEER_REJECTED ,
107+ peerId : peerId ,
108+ statusCode : statusCode ,
109+ statusDesc : statusDesc ,
110+ requestId : requestId
108111 } ,
109112 success : null
110113 } ;
@@ -120,7 +123,7 @@ export class FilterCore {
120123 pubsubTopic : PubsubTopic ,
121124 peerId : PeerId ,
122125 contentTopics : ContentTopic [ ]
123- ) : Promise < CoreProtocolResult > {
126+ ) : Promise < FilterCoreResult > {
124127 let stream : Stream | undefined ;
125128 try {
126129 stream = await this . streamManager . getStream ( peerId ) ;
@@ -132,7 +135,7 @@ export class FilterCore {
132135 return {
133136 success : null ,
134137 failure : {
135- error : ProtocolError . NO_STREAM_AVAILABLE ,
138+ error : FilterError . NO_STREAM_AVAILABLE ,
136139 peerId : peerId
137140 }
138141 } ;
@@ -150,7 +153,7 @@ export class FilterCore {
150153 return {
151154 success : null ,
152155 failure : {
153- error : ProtocolError . GENERIC_FAIL ,
156+ error : FilterError . GENERIC_FAIL ,
154157 peerId : peerId
155158 }
156159 } ;
@@ -165,7 +168,7 @@ export class FilterCore {
165168 public async unsubscribeAll (
166169 pubsubTopic : PubsubTopic ,
167170 peerId : PeerId
168- ) : Promise < CoreProtocolResult > {
171+ ) : Promise < FilterCoreResult > {
169172 const stream = await this . streamManager . getStream ( peerId ) ;
170173
171174 const request = FilterSubscribeRpc . createUnsubscribeAllRequest ( pubsubTopic ) ;
@@ -181,7 +184,7 @@ export class FilterCore {
181184 if ( ! res || ! res . length ) {
182185 return {
183186 failure : {
184- error : ProtocolError . NO_RESPONSE ,
187+ error : FilterError . NO_RESPONSE ,
185188 peerId : peerId
186189 } ,
187190 success : null
@@ -197,7 +200,7 @@ export class FilterCore {
197200 ) ;
198201 return {
199202 failure : {
200- error : ProtocolError . REMOTE_PEER_REJECTED ,
203+ error : FilterError . REMOTE_PEER_REJECTED ,
201204 peerId : peerId
202205 } ,
203206 success : null
@@ -210,7 +213,7 @@ export class FilterCore {
210213 } ;
211214 }
212215
213- public async ping ( peerId : PeerId ) : Promise < CoreProtocolResult > {
216+ public async ping ( peerId : PeerId ) : Promise < FilterCoreResult > {
214217 let stream : Stream | undefined ;
215218 try {
216219 stream = await this . streamManager . getStream ( peerId ) ;
@@ -222,7 +225,7 @@ export class FilterCore {
222225 return {
223226 success : null ,
224227 failure : {
225- error : ProtocolError . NO_STREAM_AVAILABLE ,
228+ error : FilterError . NO_STREAM_AVAILABLE ,
226229 peerId : peerId
227230 }
228231 } ;
@@ -244,7 +247,7 @@ export class FilterCore {
244247 return {
245248 success : null ,
246249 failure : {
247- error : ProtocolError . GENERIC_FAIL ,
250+ error : FilterError . GENERIC_FAIL ,
248251 peerId : peerId
249252 }
250253 } ;
@@ -254,7 +257,7 @@ export class FilterCore {
254257 return {
255258 success : null ,
256259 failure : {
257- error : ProtocolError . NO_RESPONSE ,
260+ error : FilterError . NO_RESPONSE ,
258261 peerId : peerId
259262 }
260263 } ;
@@ -270,7 +273,7 @@ export class FilterCore {
270273 return {
271274 success : null ,
272275 failure : {
273- error : ProtocolError . REMOTE_PEER_REJECTED ,
276+ error : FilterError . REMOTE_PEER_REJECTED ,
274277 peerId : peerId
275278 }
276279 } ;
0 commit comments