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 up[CLOSED] Solve unnecessary state changes upon start #138
Comments
This comment has been minimized.
This comment has been minimized.
|
Thanks - this looks good! |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Thursday Sep 11, 2014 at 11:35 GMT
Originally opened as https://github.com/feross/bittorrent-client/pull/42
When a torrent receives metadata, _onMetadata() is called. Then for each wire in the torrent, _onWireWithMetadata() sends the message "interested" to the peer, as it always starts like that. Later on the function calls _updateSelections(). As there is no selection yet, it now sends "not interested". After the function returns, _onMetadata() calls _onStorage() which selects the entire torrent, thus sending another "interested" message to the peer.
I'm not sure but probably it's not necessary to _updateSelections() in _onWireWithMetadata() as later on it will be called. However, _onWire() also calls it when a new wire in the torrent is being created with metadata.
marmolejo included the following code: https://github.com/feross/bittorrent-client/pull/42/commits