Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 17 additions & 15 deletions beacon_node/network/src/sync/block_lookups/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -349,16 +349,16 @@ impl<T: BeaconChainTypes> BlockLookups<T> {
}

// Do not re-request a block that is already being requested
if let Some((&lookup_id, lookup)) = self
if let Some((&lookup_id, _lookup)) = self
.single_block_lookups
.iter_mut()
.find(|(_id, lookup)| lookup.is_for_block(block_root))
{
if let Some(block_component) = block_component {
let imported = lookup.add_child_components(block_component);
if !imported {
debug!(?block_root, "Lookup child component ignored");
}
// A lookup for this root already exists. Drop any gossip-provided component: injecting
// it could collide with an in-flight request, and the existing lookup will complete on
// its own.
if block_component.is_some() {
debug!(?block_root, "Lookup child component ignored");
}

if let Err(e) = self.add_peers_to_lookup_and_ancestors(lookup_id, peers, peer_type, cx)
Expand Down Expand Up @@ -389,16 +389,18 @@ impl<T: BeaconChainTypes> BlockLookups<T> {

// If we know that this lookup has unknown parent (is awaiting a parent lookup to resolve),
// signal here to hold processing downloaded data.
let mut lookup =
SingleBlockLookup::new(block_root, peers, peer_type, cx.next_id(), awaiting_parent);
let id = cx.next_id();
let lookup = SingleBlockLookup::new(
block_root,
peers,
peer_type,
id,
block_component,
awaiting_parent,
cx.spec(),
);
let _guard = lookup.span.clone().entered();

// Add block components to the new request
if let Some(block_component) = block_component {
lookup.add_child_components(block_component);
}

let id = lookup.id;
let lookup = match self.single_block_lookups.entry(id) {
Entry::Vacant(entry) => entry.insert(lookup),
Entry::Occupied(_) => {
Expand Down Expand Up @@ -562,7 +564,7 @@ impl<T: BeaconChainTypes> BlockLookups<T> {

for (id, lookup) in self.single_block_lookups.iter_mut() {
if lookup.is_awaiting_parent(parent_root, imported_parent) {
lookup.resolve_awaiting_parent();
lookup.resolve_awaiting_parent(cx.spec());
debug!(
?imported_parent,
id,
Expand Down
Loading