简体   繁体   English

Erlang bittorrent件请求

[英]Erlang bittorrent pieces request

I'm currently working on a BitTorrent client in Erlang. 我目前正在使用Erlang的BitTorrent客户端。 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. 似乎好像下载了最后一块,但我似乎无法将其哈希值与从torrent文件中检索的哈希值匹配。 I guess I'm not really asking for a solution here, but rather if there's something in particular 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. 最后一块与其他对象一样经过SHA1哈希处理,尽管它较小。

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. 首先在获得最后一个块并将其与文件进行比较时将其打印出来。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM