explicit `int` array indices for Nim 2.0 (#5306)

In Nim, when using a `distinct` capacity for an array, `int` lookups
don't work. Therefore, define the array with `int` capacity.
This commit is contained in:
Etan Kissling 2023-08-17 19:26:08 +02:00 committed by GitHub
parent 49729e1ef3
commit 13f436bc24
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 3 deletions

View File

@ -65,7 +65,7 @@ type
## "free" attestations with those found in past blocks - these votes
## are tracked separately in the fork choice.
candidates*: array[ATTESTATION_LOOKBACK, AttestationTable] ## \
candidates*: array[ATTESTATION_LOOKBACK.int, AttestationTable] ## \
## We keep one item per slot such that indexing matches slot number
## together with startingSlot

View File

@ -131,7 +131,7 @@ type
timeOffset*: Opt[TimeOffset]
EpochSelectionProof* = object
signatures*: array[SLOTS_PER_EPOCH, Opt[ValidatorSig]]
signatures*: array[SLOTS_PER_EPOCH.int, Opt[ValidatorSig]]
sync_committee_index*: IndexInSyncCommittee
SyncCommitteeSelectionProof* = seq[EpochSelectionProof]
@ -1350,7 +1350,7 @@ proc waitForBlock*(
iterator chunks*[T](data: openArray[T], maxCount: Positive): seq[T] =
for i in countup(0, len(data) - 1, maxCount):
yield @(data.toOpenArray(i, min(i + maxCount, len(data)) - 1))
func init*(t: typedesc[TimeOffset], duration: Duration): TimeOffset =
TimeOffset(value: duration.nanoseconds)