clean up quarantine

This commit is contained in:
Jacek Sieka 2020-08-05 16:19:43 +02:00
parent 983d931a83
commit deaeb62de3
No known key found for this signature in database
GPG Key ID: A1B09461ABB656B8

View File

@ -40,16 +40,16 @@ func checkMissing*(quarantine: var QuarantineRef): seq[FetchRecord] =
if countOnes(v.tries.uint64) == 1: if countOnes(v.tries.uint64) == 1:
result.add(FetchRecord(root: k)) result.add(FetchRecord(root: k))
func addMissing*(quarantine: var QuarantineRef, broot: Eth2Digest) {.inline.} = func addMissing*(quarantine: var QuarantineRef, root: Eth2Digest) =
if broot notin quarantine.orphans: ## Schedule the download a the given block
discard quarantine.missing.hasKeyOrPut(broot, MissingBlock()) if root notin quarantine.orphans:
# If the block is in orphans, we no longer need it
discard quarantine.missing.hasKeyOrPut(root, MissingBlock())
func add*(quarantine: var QuarantineRef, dag: ChainDAGRef, func add*(quarantine: var QuarantineRef, dag: ChainDAGRef,
sblck: SignedBeaconBlock) = signedBlock: SignedBeaconBlock) =
## Adds block to quarantine's `orphans` and `missing` lists. ## Adds block to quarantine's `orphans` and `missing` lists.
quarantine.orphans[sblck.root] = sblck quarantine.orphans[signedBlock.root] = signedBlock
quarantine.missing.del(sblck.root) quarantine.missing.del(signedBlock.root)
let parentRoot = sblck.message.parent_root quarantine.addMissing(signedBlock.message.parent_root)
if parentRoot notin quarantine.orphans:
quarantine.addMissing(parentRoot)