Comparing version
@@ -0,1 +1,11 @@ | ||
<a name="0.24.3"></a> | ||
## [0.24.3](https://github.com/libp2p/js-libp2p/compare/v0.24.2...v0.24.3) (2018-12-14) | ||
### Bug Fixes | ||
* not started yet ([#297](https://github.com/libp2p/js-libp2p/issues/297)) ([fdfb7b4](https://github.com/libp2p/js-libp2p/commit/fdfb7b4)) | ||
<a name="0.24.2"></a> | ||
@@ -2,0 +12,0 @@ ## [0.24.2](https://github.com/libp2p/js-libp2p/compare/v0.24.1...v0.24.2) (2018-12-04) |
{ | ||
"name": "libp2p", | ||
"version": "0.24.2", | ||
"version": "0.24.3", | ||
"description": "JavaScript base class for libp2p bundles", | ||
@@ -53,3 +53,3 @@ "leadMaintainer": "Jacob Heun <jacobheun@gmail.com>", | ||
"libp2p-ping": "~0.8.3", | ||
"libp2p-switch": "~0.41.2", | ||
"libp2p-switch": "~0.41.3", | ||
"libp2p-websockets": "~0.12.0", | ||
@@ -56,0 +56,0 @@ "mafmt": "^6.0.2", |
@@ -5,6 +5,6 @@ 'use strict' | ||
const EventEmitter = require('events').EventEmitter | ||
const assert = require('assert') | ||
const debug = require('debug') | ||
const log = debug('libp2p') | ||
log.error = debug('libp2p:error') | ||
const errCode = require('err-code') | ||
@@ -28,3 +28,8 @@ const each = require('async/each') | ||
const NOT_STARTED_ERROR_MESSAGE = 'The libp2p node is not started yet' | ||
const notStarted = (action, state) => { | ||
return errCode( | ||
new Error(`libp2p cannot ${action} when not started; state is ${state}`), | ||
'ERR_NODE_NOT_STARTED' | ||
) | ||
} | ||
@@ -222,4 +227,2 @@ /** | ||
dial (peer, callback) { | ||
assert(this.isStarted(), NOT_STARTED_ERROR_MESSAGE) | ||
this.dialProtocol(peer, null, callback) | ||
@@ -239,3 +242,5 @@ } | ||
dialProtocol (peer, protocol, callback) { | ||
assert(this.isStarted(), NOT_STARTED_ERROR_MESSAGE) | ||
if (!this.isStarted()) { | ||
return callback(notStarted('dial', this.state._state)) | ||
} | ||
@@ -268,3 +273,5 @@ if (typeof protocol === 'function') { | ||
dialFSM (peer, protocol, callback) { | ||
assert(this.isStarted(), NOT_STARTED_ERROR_MESSAGE) | ||
if (!this.isStarted()) { | ||
return callback(notStarted('dial', this.state._state)) | ||
} | ||
@@ -290,4 +297,2 @@ if (typeof protocol === 'function') { | ||
hangUp (peer, callback) { | ||
assert(this.isStarted(), NOT_STARTED_ERROR_MESSAGE) | ||
this._getPeerInfo(peer, (err, peerInfo) => { | ||
@@ -302,3 +307,3 @@ if (err) { return callback(err) } | ||
if (!this.isStarted()) { | ||
return callback(new Error(NOT_STARTED_ERROR_MESSAGE)) | ||
return callback(notStarted('ping', this.state._state)) | ||
} | ||
@@ -474,8 +479,8 @@ | ||
(cb) => { | ||
// Ensures idempotency for restarts | ||
this._switch.transport.removeAll(cb) | ||
this.connectionManager.stop() | ||
this._switch.stop(cb) | ||
}, | ||
(cb) => { | ||
this.connectionManager.stop() | ||
this._switch.stop(cb) | ||
// Ensures idempotent restarts | ||
this._switch.transport.removeAll(cb) | ||
} | ||
@@ -482,0 +487,0 @@ ], (err) => { |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
10885272
2.9%112155
3.13%Updated