Skip to content

Commit

Permalink
fix: only replenish offerPool if needed
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremyckahn committed Dec 4, 2022
1 parent 50864cc commit 65ca75b
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/torrent.js
Original file line number Diff line number Diff line change
Expand Up @@ -244,9 +244,14 @@ export const joinRoom = initGuard(occupiedRooms, (config, ns) => {

const onDisconnect = (peer, peerId, offerId) => {
delete connectedPeers[peerId]
delete offerPool[offerId]
peer.destroy()
offerPool = {...offerPool, ...makeOffers(1)}

const isInOfferPool = offerId in offerPool

if (isInOfferPool) {
delete offerPool[offerId]
offerPool = {...offerPool, ...makeOffers(1)}
}
}

let announceSecs = defaultAnnounceSecs
Expand Down

0 comments on commit 65ca75b

Please sign in to comment.