ensure HashList/HashArray maxChunks power of 2 in int64 (#2394)

This commit is contained in:
tersec 2021-03-10 09:13:32 +00:00 committed by GitHub
parent 74a75d05a0
commit 236a9cdd1d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 1 deletions

View File

@ -1,5 +1,5 @@
# beacon_chain
# Copyright (c) 2018-2020 Status Research & Development GmbH
# Copyright (c) 2018-2021 Status Research & Development GmbH
# Licensed and distributed under either of
# * MIT license (license terms in the root directory or at https://opensource.org/licenses/MIT).
# * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0).
@ -168,6 +168,7 @@ template maxChunks*(a: HashList|HashArray): int64 =
template maxDepth*(a: HashList|HashArray): int =
## Layer where data is
static: doAssert a.maxChunks <= high(int64) div 2
layer(nextPow2(a.maxChunks.uint64).int64)
template chunkIdx(a: HashList|HashArray, dataIdx: int64): int64 =