@@ -71,6 +71,7 @@ export class WakuHeadless {
71
71
) {
72
72
this . waku = null as unknown as LightNode ;
73
73
this . networkConfig = this . buildNetworkConfig ( networkConfig ) ;
74
+ console . log ( "Network config on construction:" , this . networkConfig ) ;
74
75
this . lightpushNode = lightpushNode || null ;
75
76
this . enrBootstrap = enrBootstrap || null ;
76
77
@@ -132,50 +133,6 @@ export class WakuHeadless {
132
133
} as NetworkConfig ;
133
134
}
134
135
135
- async pushMessage (
136
- contentTopic : string ,
137
- payload : string ,
138
- ) : Promise < SerializableSDKProtocolResult > {
139
- if ( ! this . waku ) {
140
- throw new Error ( "Waku node not started" ) ;
141
- }
142
-
143
- let processedPayload : Uint8Array ;
144
- try {
145
- const binaryString = atob ( payload ) ;
146
- const bytes = new Uint8Array ( binaryString . length ) ;
147
- for ( let i = 0 ; i < binaryString . length ; i ++ ) {
148
- bytes [ i ] = binaryString . charCodeAt ( i ) ;
149
- }
150
- processedPayload = bytes ;
151
- } catch ( e ) {
152
- processedPayload = new TextEncoder ( ) . encode ( payload ) ;
153
- }
154
-
155
- try {
156
- const lightPush = this . waku . lightPush ;
157
- if ( ! lightPush ) {
158
- throw new Error ( "Lightpush service not available" ) ;
159
- }
160
-
161
- const encoder = this . waku . createEncoder ( { contentTopic } ) ;
162
-
163
- const result = await lightPush . send ( encoder , {
164
- payload : processedPayload ,
165
- timestamp : new Date ( ) ,
166
- } ) ;
167
-
168
- const serializableResult = makeSerializable ( result ) ;
169
-
170
- return serializableResult ;
171
- } catch ( error ) {
172
- console . error ( "Error sending message via lightpush:" , error ) ;
173
- throw new Error (
174
- `Failed to send message: ${ error instanceof Error ? error . message : String ( error ) } ` ,
175
- ) ;
176
- }
177
- }
178
-
179
136
async pushMessageV3 (
180
137
contentTopic : string ,
181
138
payload : string ,
@@ -184,6 +141,9 @@ export class WakuHeadless {
184
141
if ( ! this . waku ) {
185
142
throw new Error ( "Waku node not started" ) ;
186
143
}
144
+ console . log ( "Pushing message via v3 lightpush:" , contentTopic , payload , pubsubTopic ) ;
145
+ console . log ( "Waku node:" , this . waku ) ;
146
+ console . log ( "Network config:" , this . networkConfig ) ;
187
147
188
148
let processedPayload : Uint8Array ;
189
149
try {
@@ -204,6 +164,9 @@ export class WakuHeadless {
204
164
}
205
165
206
166
const encoder = this . waku . createEncoder ( { contentTopic } ) ;
167
+ console . log ( "Encoder:" , encoder ) ;
168
+ console . log ( "Pubsub topic:" , pubsubTopic ) ;
169
+ console . log ( "Encoder pubsub topic:" , encoder . pubsubTopic ) ;
207
170
208
171
if ( pubsubTopic && pubsubTopic !== encoder . pubsubTopic ) {
209
172
console . warn (
@@ -229,6 +192,7 @@ export class WakuHeadless {
229
192
) ;
230
193
}
231
194
} catch ( error ) {
195
+ console . error ( "Couldn't send message via preferred lightpush node:" , error ) ;
232
196
result = await lightPush . send ( encoder , {
233
197
payload : processedPayload ,
234
198
timestamp : new Date ( ) ,
@@ -290,27 +254,14 @@ export class WakuHeadless {
290
254
console . warn ( "ignore previous waku stop error" ) ;
291
255
}
292
256
293
- if ( options . networkConfig ) {
294
- this . networkConfig = options . networkConfig ;
295
- }
257
+ // if (options.networkConfig) {
258
+ // this.networkConfig = options.networkConfig;
259
+ // console.log("Network config on createWakuNode:", this.networkConfig);
260
+ // }
296
261
297
262
let libp2pConfig : any = {
298
263
...options . libp2p ,
299
264
filterMultiaddrs : false ,
300
- connectionManager : {
301
- minConnections : 1 ,
302
- maxConnections : 50 ,
303
- connectionGater : {
304
- denyDialPeer : ( ) => false ,
305
- denyDialMultiaddr : ( ) => false ,
306
- denyInboundConnection : ( ) => false ,
307
- denyOutboundConnection : ( ) => false ,
308
- denyInboundEncryptedConnection : ( ) => false ,
309
- denyOutboundEncryptedConnection : ( ) => false ,
310
- denyInboundUpgradedConnection : ( ) => false ,
311
- denyOutboundUpgradedConnection : ( ) => false ,
312
- } ,
313
- } ,
314
265
} ;
315
266
316
267
if ( this . enrBootstrap && this . shouldUseCustomBootstrap ( options ) ) {
@@ -356,6 +307,7 @@ export class WakuHeadless {
356
307
await this . waku . dial ( this . lightpushNode ) ;
357
308
} catch {
358
309
// Ignore dial errors
310
+ console . warn ( "Failed to dial preferred lightpush node:" , this . lightpushNode ) ;
359
311
}
360
312
}
361
313
0 commit comments