Skip to content
This repository has been archived by the owner on Aug 23, 2019. It is now read-only.

Commit

Permalink
feat: sort available transports by priority
Browse files Browse the repository at this point in the history
  • Loading branch information
dryajov committed Apr 7, 2017
1 parent ea3b9ff commit 6403f28
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,15 @@ function Swarm (peerInfo, peerBook) {

// Only listen on transports we actually have addresses for
return myTransports.filter((ts) => this.transports[ts].filter(myAddrs).length > 0)
.sort((a, b) => {
if ((this.transports[a] && this.transports[b]) &&
(this.transports[a].priority && this.transports[b].priority)) {
return this.transports[a].priority - this.transports[b].priority
}

return 0
})

}

// higher level (public) API
Expand Down

0 comments on commit 6403f28

Please sign in to comment.