fix: filter invalid checkpoints from fallback

This commit is contained in:
Noah Citron 2023-02-12 12:25:04 -05:00
parent ef5a6a216f
commit adae2b0816
1 changed files with 10 additions and 1 deletions

View File

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