From 966363890be5c9c788616615879b35b31b206439 Mon Sep 17 00:00:00 2001 From: Hsiao-Wei Wang Date: Tue, 30 Jun 2020 19:16:18 +0800 Subject: [PATCH] PR feedback from @ericsson49: fix when `len(bytez) > BYTES_PER_CUSTODY_ATOM` --- specs/phase1/custody-game.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/specs/phase1/custody-game.md b/specs/phase1/custody-game.md index 8bcfc04335..6cc838935f 100644 --- a/specs/phase1/custody-game.md +++ b/specs/phase1/custody-game.md @@ -229,7 +229,8 @@ Given one set of data, return the custody atoms: each atom will be combined with ```python def get_custody_atoms(bytez: bytes) -> Sequence[bytes]: - bytez += b'\x00' * ((BYTES_PER_CUSTODY_ATOM - len(bytez)) % BYTES_PER_CUSTODY_ATOM) # right-padding + length_remainder = len(bytez) % BYTES_PER_CUSTODY_ATOM + bytez += b'\x00' * ((BYTES_PER_CUSTODY_ATOM - length_remainder) % BYTES_PER_CUSTODY_ATOM) # right-padding return [ bytez[i:i + BYTES_PER_CUSTODY_ATOM] for i in range(0, len(bytez), BYTES_PER_CUSTODY_ATOM)