remove more int64 usage (#2369)
* remove more int64 usage * explain loop bounds
This commit is contained in:
parent
3276dfc683
commit
2b5a3a6810
|
@ -351,13 +351,19 @@ proc getAttestationsForBlock*(pool: var AttestationPool,
|
||||||
cache: var StateCache): seq[Attestation] =
|
cache: var StateCache): seq[Attestation] =
|
||||||
## Retrieve attestations that may be added to a new block at the slot of the
|
## Retrieve attestations that may be added to a new block at the slot of the
|
||||||
## given state
|
## given state
|
||||||
let newBlockSlot = state.slot
|
let newBlockSlot = state.slot.uint64
|
||||||
var attestations: seq[AttestationEntry]
|
var attestations: seq[AttestationEntry]
|
||||||
|
|
||||||
pool.updateAttestationsCache(state)
|
pool.updateAttestationsCache(state)
|
||||||
|
|
||||||
for i in max(1, newBlockSlot.int64 - ATTESTATION_LOOKBACK.int64) ..
|
# Consider attestations from the current slot and ranging back up to
|
||||||
newBlockSlot.int64:
|
# ATTESTATION_LOOKBACK slots, excluding the special genesis slot. As
|
||||||
|
# unsigned subtraction (mostly avoided in this codebase, partly as a
|
||||||
|
# consequence) will otherwise wrap through zero, clamp value which's
|
||||||
|
# subtracted so that slots through ATTESTATION_LOOKBACK don't do so.
|
||||||
|
for i in max(
|
||||||
|
1'u64, newBlockSlot - min(newBlockSlot, ATTESTATION_LOOKBACK)) ..
|
||||||
|
newBlockSlot:
|
||||||
let maybeSlotData = getAttestationsForSlot(pool, i.Slot)
|
let maybeSlotData = getAttestationsForSlot(pool, i.Slot)
|
||||||
if maybeSlotData.isSome:
|
if maybeSlotData.isSome:
|
||||||
insert(attestations, maybeSlotData.get.attestations)
|
insert(attestations, maybeSlotData.get.attestations)
|
||||||
|
|
|
@ -583,8 +583,7 @@ proc updateValidatorMetrics*(node: BeaconNode) =
|
||||||
|
|
||||||
if i < 64:
|
if i < 64:
|
||||||
attached_validator_balance.set(
|
attached_validator_balance.set(
|
||||||
min(balance, int64.high.uint64).int64,
|
balance.toGaugeValue, labelValues = [shortLog(v.pubkey)])
|
||||||
labelValues = [shortLog(v.pubkey)])
|
|
||||||
else:
|
else:
|
||||||
inc i
|
inc i
|
||||||
total += balance
|
total += balance
|
||||||
|
|
Loading…
Reference in New Issue