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

Commit 8bbaf7a

Browse files
committed
feat: sort available transports by priority
1 parent cbd2a32 commit 8bbaf7a

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/index.js

+9
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,15 @@ function Swarm (peerInfo, peerBook) {
6363

6464
// Only listen on transports we actually have addresses for
6565
return myTransports.filter((ts) => this.transports[ts].filter(myAddrs).length > 0)
66+
.sort((a, b) => {
67+
if ((this.transports[a] && this.transports[b]) &&
68+
(this.transports[a].priority && this.transports[b].priority)) {
69+
return this.transports[a].priority - this.transports[b].priority
70+
}
71+
72+
return 0
73+
})
74+
6675
}
6776

6877
// higher level (public) API

0 commit comments

Comments
 (0)