Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.
Sign upBREAKING: Many fixes; all leaks fixed #762
Conversation
### Added
- `client.listening` property to signal whether TCP server is listening
for incoming
connections.
### Changed
- Merged `Swarm` class into `Torrent` object. Properties on
`torrent.swarm` (like
`torrent.swarm.wires`) now exist on `torrent` (e.g. `torrent.wires`).
- `torrent.addPeer` can no longer be called before the `infoHash` event
has been
emitted.
- Remove `torrent.on('listening')` event. Use `client.on('listening')`
instead.
- Remove support from `TCPPool` for listening on multiple ports. This
was not used by
WebTorrent and just added complexity. There is now a single `TCPPool`
instance for the
whole WebTorrent client.
- Deprecate: Do not use `client.download()` anymore. Use `client.add()`
instead.
- Deprecate: Do not use `torrent.swarm` anymore. Use `torrent` instead.
### Fixed
- When there is a `torrent.on('error')` listener, don't also emit
`client.on('error')`.
- Do not return existing torrent object when duplicate torrent is
added. Fire an
`'error'` event instead.
- Memory leak of `Torrent` object caused by `RarityMap`
- Memory leak of `Torrent` object caused by `TCPPool`
- `client.ratio` and `torrent.ratio` are now calculated as `uploaded /
received` instead
of `uploaded / downloaded`.
- Only pass `torrent.infoHash` to the Chunk Store constructor, instead
of the `Torrent`
instance itself, to prevent accidental memory leaks of the `Torrent`
object by the
store. (Open an issue if you were using other properties. They can be
re-added.)
- Non-fatal errors with a single torrent will be emitted at
`torrent.on('error')`. You
should listen to this event. Previously, all torrent errors were also
emitted on
`client.on('error')` and handling `torrent.on('error')` was optional.
This design is
better since now it is possible to distinguish between fatal client
errors
(`client.on('error')`) when the whole client becomes unusable versus
recoverable errors
where only a single torrent fails (`torrent.on('error')`) but the
client can continue to
be used. However, if there is no `torrent.on('error')` event, then
the error will be
forwarded to `client.on('error')`. This prevents crashing the client
when the user
only has a listener on the client, but it makes it impossible for
them to determine
a client error versus a torrent error.
- Errors creating a torrent with `client.seed` are now emitted on the
returned `torrent`
object instead of the client (unless there is no event listeners on
`torrent.on('error')` as previously discussed). The torrent object is
now also destroyed
automatically for the user, as was probably expected.
- If `client.get` is passed a `Torrent` instance, it now only returns
it if it is present
in the client.
| var hat = require('hat') | ||
| var Swarm = require('../lib/swarm') | ||
| var test = require('tape') | ||
| // var hat = require('hat') |
This comment has been minimized.
This comment has been minimized.
dcposch
Apr 21, 2016
•
Contributor
Might want to delete the commented out files. Or are you planning to port the tests to use torrent instead of swarm later?
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
This is awesome. Also when you exclude release notes and commented-out tests, you're mostly removing code. |
This comment has been minimized.
This comment has been minimized.
|
Swarm tests are disabled for now, since there's no Swarm class anymore to test. It's part of Torrent. I'll see what testing is worth keeping and what is redundant in a future PR. |
This comment has been minimized.
This comment has been minimized.
|
I want to get a PR ready for |
This comment has been minimized.
This comment has been minimized.
|
I think this is the PR everybody was waiting for :D. |
This comment has been minimized.
This comment has been minimized.
|
PR to webtorrent-cli wasn't so bad: webtorrent/webtorrent-cli#6 |
This comment has been minimized.
This comment has been minimized.
lock
bot
commented
May 4, 2018
|
This thread has been automatically locked because it has not had recent activity. To discuss futher, please open a new issue. |
feross commentedApr 21, 2016
•
edited
Added
client.listeningproperty to signal whether TCP server is listening for incomingconnections.
client.dhtPortproperty to show the actual chosen DHT port (parallel toclient.torrentPortfor the TCP torrent listening server)Changed
Swarmclass intoTorrentobject. Properties ontorrent.swarm(liketorrent.swarm.wires) now exist ontorrent(e.g.torrent.wires). Deleted a ton of code!torrent.swarmanymore. Usetorrentinstead.torrent.addPeercan no longer be called before theinfoHashevent has beenemitted.
torrent.on('listening')event. Useclient.on('listening')instead.TCPPoolfor listening on multiple ports. This was not used byWebTorrent and just added complexity. There is now a single
TCPPoolinstance for thewhole WebTorrent client.
client.download()anymore. Useclient.add()instead.torrent.infoHashto the Chunk Store constructor, instead of theTorrentinstance itself, to prevent accidental memory leaks of the
Torrentobject by thestore. (Open an issue if you were using other properties. They can be re-added.)
torrent.on('error'). Youshould listen to this event. Previously, all torrent errors were also emitted on
client.on('error')and handlingtorrent.on('error')was optional. The new design isbetter since now it is possible to distinguish between fatal client errors
(
client.on('error')) when the whole client becomes unusable versus recoverable errorswhere only a single torrent fails (
torrent.on('error')) but the client can continue tobe used. However, if there is no
torrent.on('error')event, then the error will beforwarded to
client.on('error'). This prevents crashing the client when the useronly has a listener on the client, but it makes it impossible for them to determine
a client error versus a torrent error.
Fixed
client.getis passed aTorrentinstance, it now only returns it if it is presentin the client.
client.seedare now emitted on the returnedtorrentobject instead of the client (unless there is no event listeners on
torrent.on('error')as previously discussed). The torrent object is now also destroyedautomatically for the user, as was probably expected.
'error'event instead.Torrentobject caused by many internal subclasses of WebTorrent,including
RarityMap,TCPPool,WebConn,Server,File,Torrent.client.ratioandtorrent.ratioare now calculated asuploaded / receivedinsteadof
uploaded / downloaded.Closes #721
Closes #712
Closes #635
Closes #317
Closes #248