Skip to content

Commit

Permalink
Fix piece selection algorithm in docs (#524)
Browse files Browse the repository at this point in the history
  • Loading branch information
schnerring committed Jan 6, 2024
1 parent f812bf6 commit af1274b
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion book/src/bittorrent/piece-length.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ MIN = 16 * 1024
MAX = 16 * 1024 * 1024

def piece_length(content_length):
exponent = math.log2(content_length)
exponent = math.ceil(math.log2(content_length))
length = 1 << int((exponent / 2 + 4))
return min(max(length, MIN), MAX)
```
Expand Down

0 comments on commit af1274b

Please sign in to comment.