开发者

Erlang bittorrent pieces request

开发者 https://www.devze.com 2023-01-28 13:32 出处:网络
I\'m currently working on a BitTorrent client in Erlang. Currently I\'m trying to request blocks and then build and

I'm currently working on a BitTorrent client in Erlang. Currently I'm trying to request blocks and then build and verify a piece from the downloaded blocks. Everything works as long as it is not the last piece (which is of a different size than the other pieces). It seems as if the last piece is downloaded but I can't seem to match the hash of it against the hash retrieved from the torrent-file. I guess I'm not really asking for a solution here, but rather if there's something in particula开发者_开发百科r that I should keep in mind when it comes to the hash of the last piece. Is there?


No, there is not. The last piece is SHA1-hashed just like the others, albeit it is smaller.

My guess is you have a bug around handling that last block and or piece correctly. One way, if glancing at the code fails, could be to test a known torrent and then compare received pieces to what you should have actually received. Start by printing out the last block when you get it and compare to the file.

0

精彩评论

暂无评论...
验证码 换一张
取 消