This generally looks good, and sensible. There is only one piece that seems a little dodgy. Sending back out parts of pieces before you have fully received them.
I might be misunderstanding, but until a piece is fully received, you can't hash it and check it is right. This could therefore lead to many clients having partially incorrect pieces, if they keep passing it around.
I've found (and I'm not 100% sure why) that most bittorrent clients do find they get some number of dodgy pieces over time, so this isn't just a theoretical problem.
Just saw the surging traffic on our download site and noticed the link from HN.
Re: Aggressive sharing. Yes and no. If the torrent is encoded as a Merkle tree, you can verify subsets of a piece. For torrents that only include piece-level hashes, a BitMate client can upload an unverified piece. However, in our experience, its rare for pieces to be corrupted (unless the uploader is maliciously uploading corrupt pieces).
Please let us have your feedback regarding the performance and stability of the client since this our first (read: pre-alpha) release.
> There is only one piece that seems a little dodgy. Sending back out parts of pieces before you have fully received them.
This is my concern too. The rest of it seems mostly compatible with BitTorrent (although I am a little concerned at there being multiple mechanisms by which this peer algorithm prefers itself, in this particular use case that behaviour seems justified and fair), but this is not playing nice.
One reason you receive incorrect pieces by the way is from people that have altered the files on their hard drive but still have their BitTorrent client running - a common case is MP3 player software rewriting the ID3 metadata, which WMP and iTunes do without asking.
If the assumption is that you will finish receiving the piece before you finish sending it out, you can start uploading mid-way. If you have a bad checksum, then o well, they fail too. The idea, however, is to maximize local-isp traffic so the more you send, the better.
I might be misunderstanding, but until a piece is fully received, you can't hash it and check it is right. This could therefore lead to many clients having partially incorrect pieces, if they keep passing it around.
I've found (and I'm not 100% sure why) that most bittorrent clients do find they get some number of dodgy pieces over time, so this isn't just a theoretical problem.