Use the `get_previous_power_of_2` function in ethereum/eth2.0-specs#1323
This commit is contained in:
parent
d88a83d482
commit
0f52d460a5
|
@ -50,8 +50,7 @@ def get_previous_power_of_two(x: int) -> int:
|
|||
"""
|
||||
Get the previous power of 2 >= the input.
|
||||
"""
|
||||
assert x >= 2
|
||||
return get_next_power_of_two(x) // 2
|
||||
return x if x <= 2 else 2 * get_previous_power_of_2(x // 2)
|
||||
```
|
||||
|
||||
## Generalized Merkle tree index
|
||||
|
|
Loading…
Reference in New Issue