feross/bittorrent-tracker — pull request #45 by astro (2014-12-10 16:41:44+00:00)
Title: Refactor the server-side code

Hi

For these big changes I'm not going to use my commit bit but want you to review. If accepted, I'm going to push future fixes and review incoming PRs. If not, I will probably start maintaining my own fork.

### Notes:
* Greatly reduced function lengths, code smells better now
* Deduplicated the HTTP/UDP handling, making it more uniform
* Renamed a few infoHash instances to info_hash fields in the process, easening the handling of protocol input
* Tried to separate the protocol bits from logic
* Expose `getSwarm()`
* Solves #44
* `getSwarm()` and Swarm objects can now be implemented by users, allowing for custom logic
* Swarm processes stuff asynchronously, enabling us to store peer data in a database or sync it between tracker instances

### Next up
* We could always use more tests
* Server-side IPv6 support
* Tracking `completed` events for scraping the `downloaded` count
* Benchmarking

### Consistent formatting of binary identifiers
In the process I dropped the capability of passing hex info_hashes to `getSwarm()` because that would put an additional requirement to anyone implementing the function themselves. It would be really helpful to have consistent conventions for info_hashes and peer_ids in the Webtorrent scope.

The options are:
* Buffers: while binary safe, can't be used as dict keys
* Binary strings: not printable, also I'm afraid of any Unicode mangling
* Hex strings: printable, safe, my favourite