Skip to content

Commit 35b4802

Browse files
committed
fix: write correct ping message
1 parent 32c176f commit 35b4802

File tree

1 file changed

+7
-5
lines changed
  • packages/kad-dht/src/routing-table

1 file changed

+7
-5
lines changed

packages/kad-dht/src/routing-table/index.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -263,13 +263,15 @@ export class RoutingTable extends TypedEventEmitter<RoutingTableEvents> implemen
263263
const connection = await this.components.connectionManager.openConnection(oldContact.peerId, options)
264264
stream = await connection.newStream(this.protocol, options)
265265

266-
const pb = pbStream(stream)
266+
const pb = pbStream(stream).pb(Message)
267267
await pb.write({
268-
type: MessageType.PING
269-
}, Message, options)
270-
const response = await pb.read(Message, options)
268+
type: MessageType.PING,
269+
closer: [],
270+
providers: []
271+
}, options)
272+
const response = await pb.read(options)
271273

272-
await pb.unwrap().close(options)
274+
await pb.unwrap().unwrap().close(options)
273275

274276
if (response.type !== MessageType.PING) {
275277
throw new InvalidMessageError(`Incorrect message type received, expected PING got ${response.type}`)

0 commit comments

Comments
 (0)