mirror of
https://github.com/fluencelabs/js-libp2p
synced 2025-04-25 02:22:14 +00:00
chore: apply suggestions from code review
Co-authored-by: Irakli Gozalishvili <contact@gozala.io>
This commit is contained in:
parent
1992609f58
commit
9b863bd453
4
.github/workflows/main.yml
vendored
4
.github/workflows/main.yml
vendored
@ -14,7 +14,7 @@ jobs:
|
||||
- uses: actions/checkout@v2
|
||||
- run: yarn
|
||||
- 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 aegir dep-check
|
||||
- uses: ipfs/aegir/actions/bundle-size@master
|
||||
@ -64,4 +64,4 @@ jobs:
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- run: yarn
|
||||
- run: cd examples && yarn && npm run test -- auto-relay
|
||||
- run: cd examples && yarn && npm run test -- auto-relay
|
||||
|
@ -19,7 +19,7 @@ const { validateAddrs } = require('./utils')
|
||||
* Handles incoming STOP requests
|
||||
*
|
||||
* @private
|
||||
* @param {object} options
|
||||
* @param {Object} options
|
||||
* @param {Connection} options.connection
|
||||
* @param {CircuitPB} options.request - The CircuitRelay protobuf request (unencoded)
|
||||
* @param {StreamHandler} options.streamHandler
|
||||
@ -50,7 +50,7 @@ module.exports.handleStop = function handleStop ({
|
||||
* Creates a STOP request
|
||||
*
|
||||
* @private
|
||||
* @param {object} options
|
||||
* @param {Object} options
|
||||
* @param {Connection} options.connection
|
||||
* @param {CircuitPB} options.request - The CircuitRelay protobuf request (unencoded)
|
||||
* @returns {Promise<MuxedStream|void>} Resolves a duplex iterable
|
||||
|
@ -48,6 +48,7 @@ class StreamHandler {
|
||||
* Encode and write array of buffers
|
||||
*
|
||||
* @param {CircuitPB} msg - An unencoded CircuitRelay protobuf message
|
||||
* @returns {void}
|
||||
*/
|
||||
write (msg) {
|
||||
log('write message type %s', msg.type)
|
||||
|
@ -52,7 +52,6 @@ const defaultOptions = {
|
||||
*/
|
||||
|
||||
/**
|
||||
* @extends EventEmitter
|
||||
*
|
||||
* @fires ConnectionManager#peer:connect Emitted when a new peer is connected.
|
||||
* @fires ConnectionManager#peer:disconnect Emitted when a peer is disconnected.
|
||||
|
@ -70,14 +70,14 @@ class ContentRouting {
|
||||
* a provider of the given key.
|
||||
*
|
||||
* @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) {
|
||||
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
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
async put (key, value, options) { // eslint-disable-line require-await
|
||||
put (key, value, options) {
|
||||
if (!this.libp2p.isStarted() || !this.dht.isStarted) {
|
||||
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)
|
||||
* @returns {Promise<GetData>}
|
||||
*/
|
||||
async get (key, options) { // eslint-disable-line require-await
|
||||
get (key, options) {
|
||||
if (!this.libp2p.isStarted() || !this.dht.isStarted) {
|
||||
throw errCode(new Error(messages.NOT_STARTED_YET), codes.DHT_NOT_STARTED)
|
||||
}
|
||||
|
@ -33,7 +33,7 @@ async function ping (node, peer) {
|
||||
|
||||
const { stream } = await node.dialProtocol(peer, PROTOCOL)
|
||||
|
||||
const start = new Date().getTime()
|
||||
const start = Date.now()
|
||||
const data = crypto.randomBytes(PING_LENGTH)
|
||||
|
||||
const [result] = await pipe(
|
||||
|
Loading…
x
Reference in New Issue
Block a user