mirror of
https://github.com/fluencelabs/js-libp2p
synced 2025-04-25 02:22:14 +00:00
chore: address other review comments
This commit is contained in:
parent
9966c6ceb2
commit
aa98bc2f0e
@ -14,7 +14,7 @@ const { validateAddrs } = require('./utils')
|
||||
* @typedef {import('libp2p-interfaces/src/connection').Connection} Connection
|
||||
* @typedef {import('libp2p-interfaces/src/stream-muxer/types').MuxedStream} MuxedStream
|
||||
* @typedef {import('../../types').CircuitRequest} CircuitRequest
|
||||
* @typedef {import('./stream-handler')<Request>} StreamHandlerT
|
||||
* @typedef {import('./stream-handler')<CircuitRequest>} StreamHandlerT
|
||||
*/
|
||||
|
||||
/**
|
||||
|
@ -24,6 +24,7 @@ const transportSymbol = Symbol.for('@libp2p/js-libp2p-circuit/circuit')
|
||||
* @typedef {import('multiaddr')} Multiaddr
|
||||
* @typedef {import('libp2p-interfaces/src/connection').Connection} Connection
|
||||
* @typedef {import('libp2p-interfaces/src/stream-muxer/types').MuxedStream} MuxedStream
|
||||
* @typedef {import('../types').CircuitRequest} CircuitRequest
|
||||
*/
|
||||
|
||||
class Circuit {
|
||||
@ -53,6 +54,7 @@ class Circuit {
|
||||
* @param {MuxedStream} props.stream
|
||||
*/
|
||||
async _onProtocol ({ connection, stream }) {
|
||||
/** @type {import('./circuit/stream-handler')<CircuitRequest>} */
|
||||
const streamHandler = new StreamHandler({ stream })
|
||||
const request = await streamHandler.read()
|
||||
|
||||
@ -101,7 +103,7 @@ class Circuit {
|
||||
remoteAddr,
|
||||
localAddr
|
||||
})
|
||||
const type = request.Type === CircuitPB.Type.HOP ? 'relay' : 'inbound'
|
||||
const type = request.type === CircuitPB.Type.HOP ? 'relay' : 'inbound'
|
||||
log('new %s connection %s', type, maConn.remoteAddr)
|
||||
|
||||
const conn = await this._upgrader.upgradeInbound(maConn)
|
||||
|
@ -95,9 +95,6 @@ class Libp2p extends EventEmitter {
|
||||
super()
|
||||
// validateConfig will ensure the config is correct,
|
||||
// and add default values where appropriate
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
this._options = validateConfig(_options)
|
||||
|
||||
/** @type {PeerId} */
|
||||
|
@ -66,10 +66,14 @@ class PeerRecord {
|
||||
/**
|
||||
* Returns true if `this` record equals the `other`.
|
||||
*
|
||||
* @param {PeerRecord} other
|
||||
* @returns {other is Record}
|
||||
* @param {unknown} other
|
||||
* @returns {boolean}
|
||||
*/
|
||||
equals (other) {
|
||||
if (!(other instanceof PeerRecord)) {
|
||||
return false
|
||||
}
|
||||
|
||||
// Validate PeerId
|
||||
if (!this.peerId.equals(other.peerId)) {
|
||||
return false
|
||||
|
Loading…
x
Reference in New Issue
Block a user