mirror of
https://gitlab.com/pulsechaincom/lighthouse-pulse.git
synced 2024-12-25 13:07:18 +00:00
Handles BlocksByRange step parameter around skip slots (#1146)
This commit is contained in:
parent
01f42a4d17
commit
1cb274008d
@ -359,13 +359,28 @@ impl<T: BeaconChainTypes> Processor<T> {
|
||||
}
|
||||
};
|
||||
|
||||
let mut block_roots = forwards_block_root_iter
|
||||
// pick out the required blocks, ignoring skip-slots and stepping by the step parameter;
|
||||
let mut last_block_root = None;
|
||||
let block_roots = forwards_block_root_iter
|
||||
.take_while(|(_root, slot)| slot.as_u64() < req.start_slot + req.count * req.step)
|
||||
// map skip slots to None
|
||||
.map(|(root, _slot)| {
|
||||
let result = if Some(root) == last_block_root {
|
||||
None
|
||||
} else {
|
||||
Some(root)
|
||||
};
|
||||
last_block_root = Some(root);
|
||||
result
|
||||
})
|
||||
.step_by(req.step as usize)
|
||||
.map(|(root, _slot)| root)
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
block_roots.dedup();
|
||||
// remove all skip slots
|
||||
let block_roots = block_roots
|
||||
.into_iter()
|
||||
.filter_map(|root| root)
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
let mut blocks_sent = 0;
|
||||
for root in block_roots {
|
||||
|
Loading…
Reference in New Issue
Block a user