fix countdown over time period (#4449)
*sigh* fixes: ``` Error: unhandled exception: beacon_chain/beacon_chain_db_light_client.nim(214, 12) `period.isSupportedBySQLite` [AssertionDefect] ```
This commit is contained in:
parent
75c7195bfd
commit
d854317646
|
@ -66,6 +66,11 @@ template ethTimeUnit*(typ: type) {.dirty.} =
|
|||
proc `div`*(x: uint64, y: typ): uint64 {.borrow, noSideEffect.}
|
||||
proc `-`*(x: typ, y: typ): uint64 {.borrow, noSideEffect.}
|
||||
|
||||
iterator countdown*(a, b: typ, step: Positive = 1): typ =
|
||||
# otherwise we use the signed version that breaks at the boundary
|
||||
for i in countdown(distinctBase(a), distinctBase(b), step):
|
||||
yield typ(i)
|
||||
|
||||
proc `*`*(x: typ, y: uint64): uint64 {.borrow, noSideEffect.}
|
||||
|
||||
proc `+=`*(x: var typ, y: typ) {.borrow, noSideEffect.}
|
||||
|
|
|
@ -47,3 +47,10 @@ suite "Beacon time":
|
|||
Epoch(5).sync_committee_period
|
||||
SyncCommitteePeriod(5).start_slot.sync_committee_period ==
|
||||
SyncCommitteePeriod(5)
|
||||
|
||||
block:
|
||||
var counts = 0
|
||||
for i in countdown(SyncCommitteePeriod(1), SyncCommitteePeriod(0)):
|
||||
counts += 1
|
||||
check:
|
||||
counts == 2
|
||||
|
|
Loading…
Reference in New Issue