@@ -18,7 +18,7 @@ import { noise } from "@chainsafe/libp2p-noise";
18
18
import { yamux } from "@chainsafe/libp2p-yamux" ;
19
19
import { PeerIdB58 } from "@fluencelabs/interfaces" ;
20
20
import { identify } from "@libp2p/identify" ;
21
- import type { PeerId , Stream } from "@libp2p/interface" ;
21
+ import type { PeerId } from "@libp2p/interface" ;
22
22
import { peerIdFromString } from "@libp2p/peer-id" ;
23
23
import { ping } from "@libp2p/ping" ;
24
24
import { webSockets } from "@libp2p/websockets" ;
@@ -180,33 +180,39 @@ export class RelayConnection implements IConnection {
180
180
) ;
181
181
}
182
182
183
- log . trace ( "sending particle..." ) ;
184
-
185
183
// Reusing active connection here
186
184
const stream = await this . lib2p2Peer . dialProtocol (
187
185
this . relayAddress ,
188
186
PROTOCOL_NAME ,
189
187
) ;
190
188
191
- log . trace ( "created stream with id " , stream . id ) ;
189
+ log . trace (
190
+ "sending particle %s to %s" ,
191
+ particle . id ,
192
+ this . relayAddress . toString ( ) ,
193
+ ) ;
194
+
192
195
const sink = stream . sink ;
193
196
194
197
await pipe ( [ fromString ( serializeToString ( particle ) ) ] , encode , sink ) ;
195
- log . trace ( "data written to sink" ) ;
198
+
199
+ log . trace (
200
+ "particle %s sent to %s" ,
201
+ particle . id ,
202
+ this . relayAddress . toString ( ) ,
203
+ ) ;
196
204
}
197
205
198
- // Await will appear after uncommenting lines in func body
199
- // eslint-disable-next-line @typescript-eslint/require-await
200
- private async processIncomingMessage ( msg : string , stream : Stream ) {
206
+ private async processIncomingMessage ( msg : string ) {
201
207
let particle : Particle | undefined ;
202
208
203
209
try {
204
210
particle = Particle . fromString ( msg ) ;
205
211
206
212
log . trace (
207
- "got particle from stream with id %s and particle id %s" ,
208
- stream . id ,
213
+ "received particle %s from %s" ,
209
214
particle . id ,
215
+ this . relayAddress . toString ( ) ,
210
216
) ;
211
217
212
218
const initPeerId = peerIdFromString ( particle . initPeerId ) ;
@@ -268,7 +274,7 @@ export class RelayConnection implements IConnection {
268
274
async ( source ) => {
269
275
try {
270
276
for await ( const msg of source ) {
271
- await this . processIncomingMessage ( msg , stream ) ;
277
+ await this . processIncomingMessage ( msg ) ;
272
278
}
273
279
} catch ( e ) {
274
280
log . error ( "connection closed: %j" , e ) ;
0 commit comments