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

Use PiecePicker for arbitrary things #536

Merged
merged 1 commit into from
Jun 19, 2022
Merged

Conversation

alanmcgovern
Copy link
Owner

PiecePicker has been simplified to have the concept of having a Piece, where each piece has 1 or more Segments.

The invariant is that once you download all the segments in 1 piece, the piece can be validated, allowing the data to be requested again if validation fails, or if it succeeds then the piece can be marked as such so it isn't requested again.

In concrete terms, there is no change to regular piece picking. However,

  1. Fetching torrent metadata
    The chunks are not independently verifiable so this data is downloaded as a single piece with N segments. Once all segments are received the data is hashed.

  2. Fetching BitTorrent v2 hashes
    The chunks are independently verifiable, so this data is represented as a series of pieces, each of which has 1 block. As soon as any block is received the data is verified.

This makes it much easier to double-request pieces, or to time out requests which aren't fulfilled due to a bad client improperly responding.

@alanmcgovern
Copy link
Owner Author

TODO:

  1. Make sure timeouts are respected
  2. Make sure peer disconnects are respected

The engine now uses the exact same logic for 'picking'
bittorrent v2 hashes, fetching the metadata and also
regular piece/block downloading.

This makes failure modes much easier to reason about.
Additionally, it's much easier to ensure that the data
is reliably fetched from other peers as the fault
tolerance of the piece picking engine will ensure
things are received, or re-requested from another
peer.
@alanmcgovern alanmcgovern force-pushed the pick-anything-using branch from cfa86e4 to 8f47fea Compare June 19, 2022 22:28
@alanmcgovern alanmcgovern merged commit b73d3dd into master Jun 19, 2022
@alanmcgovern alanmcgovern deleted the pick-anything-using branch June 19, 2022 22:29
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.

1 participant