Sync: fix backfill blob iteration order (#4993)
* Sync: fix backfill blob iteration order * Address review feedback * Add comment clarifying reason for func top-level placement
This commit is contained in:
parent
a24f3cde7e
commit
c2aa8313c3
|
@ -538,15 +538,23 @@ proc getRewindPoint*[T](sq: SyncQueue[T], failSlot: Slot,
|
||||||
safe_slot = safeSlot, fail_slot = failSlot
|
safe_slot = safeSlot, fail_slot = failSlot
|
||||||
safeSlot
|
safeSlot
|
||||||
|
|
||||||
iterator blocks*[T](sq: SyncQueue[T],
|
# This belongs inside the blocks iterator below, but can't be there due to
|
||||||
sr: SyncResult[T]): ref ForkedSignedBeaconBlock =
|
# https://github.com/nim-lang/Nim/issues/21242
|
||||||
|
func getOpt(blobs: Opt[seq[BlobSidecars]], i: int): Opt[BlobSidecars] =
|
||||||
|
if blobs.isSome:
|
||||||
|
Opt.some(blobs.get()[i])
|
||||||
|
else:
|
||||||
|
Opt.none(BlobSidecars)
|
||||||
|
|
||||||
|
iterator blocks[T](sq: SyncQueue[T],
|
||||||
|
sr: SyncResult[T]): (ref ForkedSignedBeaconBlock, Opt[BlobSidecars]) =
|
||||||
case sq.kind
|
case sq.kind
|
||||||
of SyncQueueKind.Forward:
|
of SyncQueueKind.Forward:
|
||||||
for i in countup(0, len(sr.data) - 1):
|
for i in countup(0, len(sr.data) - 1):
|
||||||
yield sr.data[i]
|
yield (sr.data[i], sr.blobs.getOpt(i))
|
||||||
of SyncQueueKind.Backward:
|
of SyncQueueKind.Backward:
|
||||||
for i in countdown(len(sr.data) - 1, 0):
|
for i in countdown(len(sr.data) - 1, 0):
|
||||||
yield sr.data[i]
|
yield (sr.data[i], sr.blobs.getOpt(i))
|
||||||
|
|
||||||
proc advanceOutput*[T](sq: SyncQueue[T], number: uint64) =
|
proc advanceOutput*[T](sq: SyncQueue[T], number: uint64) =
|
||||||
case sq.kind
|
case sq.kind
|
||||||
|
@ -678,15 +686,8 @@ proc push*[T](sq: SyncQueue[T], sr: SyncRequest[T],
|
||||||
res: Result[void, VerifierError]
|
res: Result[void, VerifierError]
|
||||||
|
|
||||||
var i=0
|
var i=0
|
||||||
for blk in sq.blocks(item):
|
for blk, blb in sq.blocks(item):
|
||||||
if reqres.get().blobs.isNone():
|
res = await sq.blockVerifier(blk[], blb, maybeFinalized)
|
||||||
res = await sq.blockVerifier(blk[],
|
|
||||||
Opt.none(BlobSidecars),
|
|
||||||
maybeFinalized)
|
|
||||||
else:
|
|
||||||
res = await sq.blockVerifier(blk[],
|
|
||||||
Opt.some(reqres.get().blobs.get()[i]),
|
|
||||||
maybeFinalized)
|
|
||||||
inc(i)
|
inc(i)
|
||||||
|
|
||||||
if res.isOk():
|
if res.isOk():
|
||||||
|
|
Loading…
Reference in New Issue