Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Protocol version 2 #3873

Merged
merged 42 commits into from
Aug 10, 2019
Merged

Protocol version 2 #3873

merged 42 commits into from
Aug 10, 2019

Conversation

ssiloti
Copy link
Collaborator

@ssiloti ssiloti commented Jul 4, 2019

No description provided.

@aldenml
Copy link
Contributor

aldenml commented Jul 4, 2019

The use of Copyright (c) ... BitTorrent Inc. in two new files is interesting

@aldenml
Copy link
Contributor

aldenml commented Jul 4, 2019

(quite a big patch :)

@arvidn or @ssiloti, info_hash_t looks like a very important public type, is it possible to have an explanation for what's the rationale behind get_best? Is it for have a "unique id/number"? I feel the API could become a little confusing or even error prone with the truncated sha256, imo

@ssiloti
Copy link
Collaborator Author

ssiloti commented Jul 4, 2019

The get_best function is used to get a unique identifier for a torrent without having to worry about whether it is a v1 only, v2 only, or hybrid torrent. It needs to return a sha1_hash for compatibility with the status quo of using the v1 info-hash directly, hence v2 info-hashes must be truncated to fit.

@codecov-io
Copy link

codecov-io commented Jul 5, 2019

Codecov Report

Merging #3873 into master will increase coverage by 0.27%.
The diff coverage is 69.84%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #3873      +/-   ##
==========================================
+ Coverage   70.03%   70.31%   +0.27%     
==========================================
  Files         438      445       +7     
  Lines       60390    63082    +2692     
  Branches     8549     8914     +365     
==========================================
+ Hits        42297    44354    +2057     
- Misses      13759    14239     +480     
- Partials     4334     4489     +155
Impacted Files Coverage Δ
include/libtorrent/add_torrent_params.hpp 100% <ø> (ø) ⬆️
include/libtorrent/part_file.hpp 100% <ø> (ø) ⬆️
include/libtorrent/storage_defs.hpp 100% <ø> (ø) ⬆️
include/libtorrent/torrent_handle.hpp 56.25% <ø> (ø) ⬆️
include/libtorrent/bt_peer_connection.hpp 80% <ø> (ø) ⬆️
include/libtorrent/peer_connection.hpp 77.11% <ø> (ø) ⬆️
include/libtorrent/aux_/session_impl.hpp 73.03% <ø> (ø) ⬆️
src/torrent_status.cpp 100% <ø> (ø) ⬆️
src/session_handle.cpp 54.9% <ø> (ø) ⬆️
include/libtorrent/settings_pack.hpp 100% <ø> (ø) ⬆️
... and 138 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a53e19d...58fce87. Read the comment docs.

@ssiloti
Copy link
Collaborator Author

ssiloti commented Jul 5, 2019

Copy link
Owner

@arvidn arvidn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You also need this change:

diff --git a/docs/gen_settings_doc.py b/docs/gen_settings_doc.py
index 5f5090af4..fa29a797a 100755
--- a/docs/gen_settings_doc.py
+++ b/docs/gen_settings_doc.py
@@ -76,6 +76,8 @@ for line in f:
         mode = 'int'
     if '#if TORRENT_ABI_VERSION == 1' in line:
         mode += 'skip'
+    if '#if TORRENT_ABI_VERSION <= 2' in line:
+        mode += 'skip'
     if '#endif' in line:
         mode = mode[0:-4]

examples/custom_storage.cpp Outdated Show resolved Hide resolved
examples/custom_storage.cpp Outdated Show resolved Hide resolved
@arvidn
Copy link
Owner

arvidn commented Jul 5, 2019

@ssiloti I ended up putting my changes in a patch: ssiloti#50

examples/client_test.cpp Outdated Show resolved Hide resolved
src/torrent.cpp Outdated
@@ -1492,7 +1510,7 @@ bool is_downloading_state(int const st)
m_save_path,
static_cast<storage_mode_t>(m_storage_mode),
m_file_priority,
m_info_hash
m_info_hash.has_v1() ? m_info_hash.v1 : m_info_hash.get(protocol_version::V2)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this basically looks like "get_worst()". would it not work to just use get_best() instead?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was probably thinking of backwards compatibility when I wrote this. In hindsight that's not an issue here since hybrid torrents will have a different v1 info-hash from an equivalent v1 only torrent.

src/torrent.cpp Outdated Show resolved Hide resolved
if (req.base == 0)
{
std::fill_n(m_hash_verified[req.file].begin() + req.index, req.count, true);
// TODO: add passing pieces to ret.hash_passed
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

doing this is not critical for the hash_picker's function I take it?

m_merkle_trees[req.file][merkle_to_flat_index(base_layer_index, req.index + i)] = hashes[i];
TORRENT_ASSERT(num_leafs == m_files.piece_length() / default_block_size);
//verify_block_hashes(m_files.file_offset(req.file) / m_files.piece_length() + req.index);
// TODO: add to failed hashes
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this also sounds like an important thing to do

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is the case where the block-hashes we got from a peer don't match what already know about the merkle tree. is that right?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is for the case were the client downloaded piece data before it knew the corresponding piece hashes. Now it has the hashes and discovered that some of the piece data was bad.

src/bt_peer_connection.cpp Outdated Show resolved Hide resolved
while (blocks_per_piece >>= 1) ++layer_index;
detail::write_uint32(layer_index, ptr);
}
#endif
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should decide what to do with this block I think. Is this here as a proposed future improvement? (if so, there should probably be a comment to that effect)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is obsolete, I'll remove it.

src/create_torrent.cpp Outdated Show resolved Hide resolved
sha256_hash const& ih = info.info_hash().v2;
ret += "xt=urn:btmh:1220";
ret += aux::to_hex(ih);
}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there should be a test for make_magnet_uri() that creates a v2-only as well as a hybrid magnet URI

@arvidn
Copy link
Owner

arvidn commented Aug 9, 2019

https://ci.appveyor.com/project/arvidn/libtorrent/builds/26577613/job/7w5x5kaschyx3nu8#L530
https://travis-ci.org/arvidn/libtorrent/jobs/569643502#L541

The info_hash_t constructor that takes a sha1_hash is explicit. I think this line has to explicitly create an info_hash_t object.

@arvidn
Copy link
Owner

arvidn commented Aug 9, 2019

did v2_symlinks.torrent get removed? make dist failed because of this file missing, I think.

@arvidn arvidn merged commit 1effdc1 into arvidn:master Aug 10, 2019
@ssiloti ssiloti mentioned this pull request Aug 10, 2019
@ssiloti ssiloti deleted the v2 branch April 13, 2020 17:17
@ssiloti ssiloti mentioned this pull request Apr 13, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants