fix: filter invalid checkpoints from fallback (#196)
* fix: filter invalid checkpoints from fallback * use iter find
This commit is contained in:
parent
ef5a6a216f
commit
8da632f8f2
|
@ -143,7 +143,15 @@ 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()
|
||||
.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")),
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue