mirror of
https://github.com/sigp/lighthouse.git
synced 2026-05-07 08:52:54 +00:00
Skip creating child lookup if parent is never created (#5803)
* Skip creating child lookup if parent is never created
This commit is contained in:
@@ -298,9 +298,12 @@ impl<T: BeaconChainTypes> BlockLookups<T> {
|
|||||||
};
|
};
|
||||||
|
|
||||||
let result = lookup.continue_requests(cx);
|
let result = lookup.continue_requests(cx);
|
||||||
self.on_lookup_result(id, result, "new_current_lookup", cx);
|
if self.on_lookup_result(id, result, "new_current_lookup", cx) {
|
||||||
self.update_metrics();
|
self.update_metrics();
|
||||||
true
|
true
|
||||||
|
} else {
|
||||||
|
false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Lookup responses */
|
/* Lookup responses */
|
||||||
@@ -622,15 +625,16 @@ impl<T: BeaconChainTypes> BlockLookups<T> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Common handler a lookup request error, drop it and update metrics
|
/// Common handler a lookup request error, drop it and update metrics
|
||||||
|
/// Returns true if the lookup is created or already exists
|
||||||
fn on_lookup_result(
|
fn on_lookup_result(
|
||||||
&mut self,
|
&mut self,
|
||||||
id: SingleLookupId,
|
id: SingleLookupId,
|
||||||
result: Result<LookupResult, LookupRequestError>,
|
result: Result<LookupResult, LookupRequestError>,
|
||||||
source: &str,
|
source: &str,
|
||||||
cx: &mut SyncNetworkContext<T>,
|
cx: &mut SyncNetworkContext<T>,
|
||||||
) {
|
) -> bool {
|
||||||
match result {
|
match result {
|
||||||
Ok(LookupResult::Pending) => {} // no action
|
Ok(LookupResult::Pending) => true, // no action
|
||||||
Ok(LookupResult::Completed) => {
|
Ok(LookupResult::Completed) => {
|
||||||
if let Some(lookup) = self.single_block_lookups.remove(&id) {
|
if let Some(lookup) = self.single_block_lookups.remove(&id) {
|
||||||
debug!(self.log, "Dropping completed lookup"; "block" => ?lookup.block_root(), "id" => id);
|
debug!(self.log, "Dropping completed lookup"; "block" => ?lookup.block_root(), "id" => id);
|
||||||
@@ -641,12 +645,14 @@ impl<T: BeaconChainTypes> BlockLookups<T> {
|
|||||||
} else {
|
} else {
|
||||||
debug!(self.log, "Attempting to drop non-existent lookup"; "id" => id);
|
debug!(self.log, "Attempting to drop non-existent lookup"; "id" => id);
|
||||||
}
|
}
|
||||||
|
false
|
||||||
}
|
}
|
||||||
Err(error) => {
|
Err(error) => {
|
||||||
debug!(self.log, "Dropping lookup on request error"; "id" => id, "source" => source, "error" => ?error);
|
debug!(self.log, "Dropping lookup on request error"; "id" => id, "source" => source, "error" => ?error);
|
||||||
metrics::inc_counter_vec(&metrics::SYNC_LOOKUP_DROPPED, &[error.into()]);
|
metrics::inc_counter_vec(&metrics::SYNC_LOOKUP_DROPPED, &[error.into()]);
|
||||||
self.drop_lookup_and_children(id);
|
self.drop_lookup_and_children(id);
|
||||||
self.update_metrics();
|
self.update_metrics();
|
||||||
|
false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user