File tree Expand file tree Collapse file tree 1 file changed +7
-3
lines changed
Expand file tree Collapse file tree 1 file changed +7
-3
lines changed Original file line number Diff line number Diff line change @@ -20,10 +20,11 @@ Swarm.prototype.announce = function (params, cb) {
2020 if ( self [ fn ] ) {
2121 self [ fn ] ( params , peer ) // process event
2222
23+ var peerType = params . compact === undefined ? 'webrtc' : 'addr'
2324 cb ( null , {
2425 complete : self . complete ,
2526 incomplete : self . incomplete ,
26- peers : self . _getPeers ( params . numwant )
27+ peers : self . _getPeers ( params . numwant , peerType )
2728 } )
2829 } else {
2930 cb ( new Error ( 'invalid event' ) )
@@ -93,13 +94,16 @@ Swarm.prototype._onAnnounce_update = function (params, peer) {
9394 }
9495}
9596
96- Swarm . prototype . _getPeers = function ( numWant ) {
97+ Swarm . prototype . _getPeers = function ( numWant , peerType ) {
9798 var peers = [ ]
9899 var ite = randomIterate ( Object . keys ( this . peers ) )
99100 while ( true ) {
100101 var peerId = ite ( )
101102 if ( peers . length >= numWant || peerId == null ) return peers
102103 var peer = this . peers [ peerId ]
103- if ( peer ) peers . push ( peer )
104+ if ( peer &&
105+ ( ( peerType === 'webrtc' && peer . socket ) || ( peerType === 'addr' && peer . ip ) ) ) {
106+ peers . push ( peer )
107+ }
104108 }
105109}
You can’t perform that action at this time.
0 commit comments