PR feedback from @ericsson49: fix when `len(bytez) > BYTES_PER_CUSTODY_ATOM`

This commit is contained in:
Hsiao-Wei Wang 2020-06-30 19:16:18 +08:00 committed by GitHub
parent eaae70b3b3
commit 966363890b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 1 deletions

View File

@ -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)