Discussion:
[libtorrent] set_file_hash()
Michael Mckeown
2016-11-05 13:59:58 UTC
Permalink
Hi,

When making a torrent where is the correct point to use set_file_hash()?
is it the case that when breaking a file up into pieces the hash of the
file is already calculated so that you don't need to do it again? none
of the examples appear to use set_file_hash().

Also for torrents that are created without storing the file hash does
Libtorrent add the hash to the torrent_info->torrent_file ( ) hash
property once it becomes aware of the file has or once the file is
complete is this a manual job?

Thanks.
Arvid Norberg
2016-11-05 19:09:44 UTC
Permalink
Post by Michael Mckeown
Hi,
When making a torrent where is the correct point to use set_file_hash()?
Yes, sometime between constructing the ``create_torrent`` object and
calling ``generate``.
Post by Michael Mckeown
is it the case that when breaking a file up into pieces the hash of the
file is already calculated so that you don't need to do it again?
Unfortunately there's really no support in libtorrent to do that. You can
do it manually, if you're scanning the files to calculate the hashes. The
built-in support relies on the storage_interface and disk_io_threads, which
provides a piece-level interface only. The file_storage object can help you
with mapping pieces to files and ranges though, so if you're fine with
synchronous I/O, it shouldn't be too bad.
Post by Michael Mckeown
none
of the examples appear to use set_file_hash().
Also for torrents that are created without storing the file hash does
Libtorrent add the hash to the torrent_info->torrent_file ( ) hash
property once it becomes aware of the file has or once the file is
complete is this a manual job?
No. Neither does it verify that a file hash specified in a torrent is
correct. There's no tie between the file hash and the chain of
"authentication" from the info-hash.
--
Arvid Norberg
Continue reading on narkive:
Loading...