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

Clarify that non power-of-two lengths are valid #129

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

alanmcgovern
Copy link

If the layer has 7 pieces, and clients wish to request this in chunks, it is valid to send two messages:

  1. index = 0, length = 4
  2. index = 4, length = 3

Let's hardcode this into the spec as a 'MUST' so anyone implementing the spec has unambiguous
guidance. Existing clients adhere to this as far as I can make out.

Addresses #128

If the layer has 7 pieces, and clients wish to request this in chunks, it is valid to send two messages:
1. index = 0, length = 4
2. index = 4, length = 3

Let's hardcode this into the spec as a 'MUST' so anyone implementing the spec has unambiguous
guidance. Existing clients  adhere to this as far as I can make out.
beps/bep_0052.rst Outdated Show resolved Hide resolved
beps/bep_0052.rst Outdated Show resolved Hide resolved
@@ -444,7 +444,8 @@ to the leaf and piece layers. Index is the offset in hashes
of the first requested hash in the base layer.
Index MUST be a multiple of length, this includes zero.
Length is the number of hashes to include from the base layer.
Length MUST be equal-to-or-greater-than two and a power of two.
Length MUST be equal-to-or-greater-than two and a power of two unless it
gets truncated by the end of the layer.
Copy link
Author

Choose a reason for hiding this comment

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

This is mimicking

'request' messages contain an index, begin, and length. The last
two are byte offsets. Length is generally a power of two unless it
gets truncated by the end of a file. All current implementations use
2^14 (16 kiB), and close connections which request an amount greater than
that.

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