Skip to content
This repository has been archived by the owner on Feb 26, 2021. It is now read-only.

Commit

Permalink
feat: implement softFail option
Browse files Browse the repository at this point in the history
  • Loading branch information
mkg20001 committed Jan 7, 2019
1 parent 693df7b commit b295fcd
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
4 changes: 3 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,13 @@ function getServerForAddress (addr) {
* @param {PeerId} options.id - Id for the crypto challenge
* @param {Transport[]} options.transports - Transport(s) for microswitch
* @param {Muxer[]} options.muxers - Muxer(s) for microswitch
* @param {boolean} options.softFail - Whether to softly fail on listen errors
*/
class Stardust {
constructor ({ transports, muxers, id }) {
constructor ({ transports, muxers, id, softFail }) {
this.switch = new MicroSwitch({ transports, addresses: [], muxers })
this.id = id
this.softFail = softFail

this.discovery = new EE()
this.discovery.tag = 'stardust'
Expand Down
10 changes: 8 additions & 2 deletions src/listener.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,14 @@ class Listener extends EventEmitter {
this.emit('listening')
callback()
}, err => {
this.emit('error', err)
callback(err)
if (this.client.softFail) {
this.emit('listening')
callback()
// dials will fail, but that's just about it
} else {
this.emit('error', err)
callback(err)
}
})
}

Expand Down

0 comments on commit b295fcd

Please sign in to comment.