From 7ceb53b0d557689dce7a06c487a97fe0f3655657 Mon Sep 17 00:00:00 2001 From: Michael Schnerring <3743342+schnerring@users.noreply.github.com> Date: Fri, 25 Aug 2023 10:08:12 +0200 Subject: [PATCH] Docs: consolidate piece selection algorithm from docs with actual implementation --- book/src/bittorrent/piece-length.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/book/src/bittorrent/piece-length.md b/book/src/bittorrent/piece-length.md index 620cdacb..522907ac 100644 --- a/book/src/bittorrent/piece-length.md +++ b/book/src/bittorrent/piece-length.md @@ -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) ```