chore: apply suggestions from code review

Co-authored-by: Irakli Gozalishvili <contact@gozala.io>
This commit is contained in:
Vasco Santos 2020-12-09 11:42:24 +01:00
parent 1992609f58
commit 9b863bd453
6 changed files with 11 additions and 11 deletions

View File

@ -14,7 +14,7 @@ jobs:
- uses: actions/checkout@v2 - uses: actions/checkout@v2
- run: yarn - run: yarn
- run: yarn lint - run: yarn lint
# - uses: gozala/typescript-error-reporter-action@v1.0.4 - uses: gozala/typescript-error-reporter-action@v1.0.8
- run: yarn build - run: yarn build
- run: yarn aegir dep-check - run: yarn aegir dep-check
- uses: ipfs/aegir/actions/bundle-size@master - uses: ipfs/aegir/actions/bundle-size@master
@ -64,4 +64,4 @@ jobs:
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v2
- run: yarn - run: yarn
- run: cd examples && yarn && npm run test -- auto-relay - run: cd examples && yarn && npm run test -- auto-relay

View File

@ -19,7 +19,7 @@ const { validateAddrs } = require('./utils')
* Handles incoming STOP requests * Handles incoming STOP requests
* *
* @private * @private
* @param {object} options * @param {Object} options
* @param {Connection} options.connection * @param {Connection} options.connection
* @param {CircuitPB} options.request - The CircuitRelay protobuf request (unencoded) * @param {CircuitPB} options.request - The CircuitRelay protobuf request (unencoded)
* @param {StreamHandler} options.streamHandler * @param {StreamHandler} options.streamHandler
@ -50,7 +50,7 @@ module.exports.handleStop = function handleStop ({
* Creates a STOP request * Creates a STOP request
* *
* @private * @private
* @param {object} options * @param {Object} options
* @param {Connection} options.connection * @param {Connection} options.connection
* @param {CircuitPB} options.request - The CircuitRelay protobuf request (unencoded) * @param {CircuitPB} options.request - The CircuitRelay protobuf request (unencoded)
* @returns {Promise<MuxedStream|void>} Resolves a duplex iterable * @returns {Promise<MuxedStream|void>} Resolves a duplex iterable

View File

@ -48,6 +48,7 @@ class StreamHandler {
* Encode and write array of buffers * Encode and write array of buffers
* *
* @param {CircuitPB} msg - An unencoded CircuitRelay protobuf message * @param {CircuitPB} msg - An unencoded CircuitRelay protobuf message
* @returns {void}
*/ */
write (msg) { write (msg) {
log('write message type %s', msg.type) log('write message type %s', msg.type)

View File

@ -52,7 +52,6 @@ const defaultOptions = {
*/ */
/** /**
* @extends EventEmitter
* *
* @fires ConnectionManager#peer:connect Emitted when a new peer is connected. * @fires ConnectionManager#peer:connect Emitted when a new peer is connected.
* @fires ConnectionManager#peer:disconnect Emitted when a peer is disconnected. * @fires ConnectionManager#peer:disconnect Emitted when a peer is disconnected.

View File

@ -70,14 +70,14 @@ class ContentRouting {
* a provider of the given key. * a provider of the given key.
* *
* @param {CID} key - The CID key of the content to find * @param {CID} key - The CID key of the content to find
* @returns {Promise<void[]>} * @returns {Promise<void>}
*/ */
async provide (key) { // eslint-disable-line require-await async provide (key) {
if (!this.routers.length) { if (!this.routers.length) {
throw errCode(new Error('No content routers available'), 'NO_ROUTERS_AVAILABLE') throw errCode(new Error('No content routers available'), 'NO_ROUTERS_AVAILABLE')
} }
return Promise.all(this.routers.map((router) => router.provide(key))) await Promise.all(this.routers.map((router) => router.provide(key)))
} }
/** /**
@ -89,7 +89,7 @@ class ContentRouting {
* @param {number} [options.minPeers] - minimum number of peers required to successfully put * @param {number} [options.minPeers] - minimum number of peers required to successfully put
* @returns {Promise<void>} * @returns {Promise<void>}
*/ */
async put (key, value, options) { // eslint-disable-line require-await put (key, value, options) {
if (!this.libp2p.isStarted() || !this.dht.isStarted) { if (!this.libp2p.isStarted() || !this.dht.isStarted) {
throw errCode(new Error(messages.NOT_STARTED_YET), codes.DHT_NOT_STARTED) throw errCode(new Error(messages.NOT_STARTED_YET), codes.DHT_NOT_STARTED)
} }
@ -106,7 +106,7 @@ class ContentRouting {
* @param {number} [options.timeout] - optional timeout (default: 60000) * @param {number} [options.timeout] - optional timeout (default: 60000)
* @returns {Promise<GetData>} * @returns {Promise<GetData>}
*/ */
async get (key, options) { // eslint-disable-line require-await get (key, options) {
if (!this.libp2p.isStarted() || !this.dht.isStarted) { if (!this.libp2p.isStarted() || !this.dht.isStarted) {
throw errCode(new Error(messages.NOT_STARTED_YET), codes.DHT_NOT_STARTED) throw errCode(new Error(messages.NOT_STARTED_YET), codes.DHT_NOT_STARTED)
} }

View File

@ -33,7 +33,7 @@ async function ping (node, peer) {
const { stream } = await node.dialProtocol(peer, PROTOCOL) const { stream } = await node.dialProtocol(peer, PROTOCOL)
const start = new Date().getTime() const start = Date.now()
const data = crypto.randomBytes(PING_LENGTH) const data = crypto.randomBytes(PING_LENGTH)
const [result] = await pipe( const [result] = await pipe(