mirror of
https://github.com/status-im/eth2.0-specs.git
synced 2025-01-10 02:35:41 +00:00
12 lines
313 B
Python
12 lines
313 B
Python
def set_bitfield_bit(bitfield, i):
|
|
"""
|
|
Set the bit in ``bitfield`` at position ``i`` to ``1``.
|
|
"""
|
|
byte_index = i // 8
|
|
bit_index = i % 8
|
|
return (
|
|
bitfield[:byte_index] +
|
|
bytes([bitfield[byte_index] | (1 << bit_index)]) +
|
|
bitfield[byte_index + 1:]
|
|
)
|