fix: filter invalid checkpoints from fallback (#196)

* fix: filter invalid checkpoints from fallback

* use iter find
This commit is contained in:
Noah Citron 2023-02-12 14:57:24 -05:00 committed by GitHub
parent ef5a6a216f
commit 8da632f8f2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 1 deletions

View File

@ -143,7 +143,15 @@ impl CheckpointFallback {
if raw.data.slots.is_empty() { if raw.data.slots.is_empty() {
return Err(eyre::eyre!("no slots")); return Err(eyre::eyre!("no slots"));
} }
Ok(raw.data.slots[0].clone())
let slot = raw
.data
.slots
.iter()
.find(|s| s.block_root.is_some())
.ok_or(eyre::eyre!("no valid slots"))?;
Ok(slot.clone())
} }
None => Err(eyre::eyre!("failed to query service")), None => Err(eyre::eyre!("failed to query service")),
} }