@@ -267,25 +267,25 @@ class IdentifyService {
267
267
* @returns {Promise<void> }
268
268
*/
269
269
async _handleIdentify ( { connection, stream } ) {
270
- let publicKey = new Uint8Array ( 0 )
271
- if ( this . peerId . pubKey ) {
272
- publicKey = this . peerId . pubKey . bytes
273
- }
270
+ try {
271
+ let publicKey = new Uint8Array ( 0 )
272
+ if ( this . peerId . pubKey ) {
273
+ publicKey = this . peerId . pubKey . bytes
274
+ }
274
275
275
- const signedPeerRecord = await this . peerStore . addressBook . getRawEnvelope ( this . peerId )
276
- const protocols = await this . peerStore . protoBook . get ( this . peerId )
276
+ const signedPeerRecord = await this . peerStore . addressBook . getRawEnvelope ( this . peerId )
277
+ const protocols = await this . peerStore . protoBook . get ( this . peerId )
277
278
278
- const message = Message . Identify . encode ( {
279
- protocolVersion : this . _host . protocolVersion ,
280
- agentVersion : this . _host . agentVersion ,
281
- publicKey,
282
- listenAddrs : this . _libp2p . multiaddrs . map ( ( ma ) => ma . bytes ) ,
283
- signedPeerRecord,
284
- observedAddr : connection . remoteAddr . bytes ,
285
- protocols
286
- } ) . finish ( )
279
+ const message = Message . Identify . encode ( {
280
+ protocolVersion : this . _host . protocolVersion ,
281
+ agentVersion : this . _host . agentVersion ,
282
+ publicKey,
283
+ listenAddrs : this . _libp2p . multiaddrs . map ( ( ma ) => ma . bytes ) ,
284
+ signedPeerRecord,
285
+ observedAddr : connection . remoteAddr . bytes ,
286
+ protocols
287
+ } ) . finish ( )
287
288
288
- try {
289
289
await pipe (
290
290
[ message ] ,
291
291
lp . encode ( ) ,
@@ -343,7 +343,11 @@ class IdentifyService {
343
343
}
344
344
345
345
// Update the protocols
346
- await this . peerStore . protoBook . set ( id , message . protocols )
346
+ try {
347
+ await this . peerStore . protoBook . set ( id , message . protocols )
348
+ } catch ( /** @type {any } */ err ) {
349
+ log . error ( 'received invalid protocols' , err )
350
+ }
347
351
}
348
352
349
353
/**
0 commit comments