mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-06 10:11:44 +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);
|
||||
self.on_lookup_result(id, result, "new_current_lookup", cx);
|
||||
self.update_metrics();
|
||||
true
|
||||
if self.on_lookup_result(id, result, "new_current_lookup", cx) {
|
||||
self.update_metrics();
|
||||
true
|
||||
} else {
|
||||
false
|
||||
}
|
||||
}
|
||||
|
||||
/* Lookup responses */
|
||||
@@ -622,15 +625,16 @@ impl<T: BeaconChainTypes> BlockLookups<T> {
|
||||
}
|
||||
|
||||
/// 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(
|
||||
&mut self,
|
||||
id: SingleLookupId,
|
||||
result: Result<LookupResult, LookupRequestError>,
|
||||
source: &str,
|
||||
cx: &mut SyncNetworkContext<T>,
|
||||
) {
|
||||
) -> bool {
|
||||
match result {
|
||||
Ok(LookupResult::Pending) => {} // no action
|
||||
Ok(LookupResult::Pending) => true, // no action
|
||||
Ok(LookupResult::Completed) => {
|
||||
if let Some(lookup) = self.single_block_lookups.remove(&id) {
|
||||
debug!(self.log, "Dropping completed lookup"; "block" => ?lookup.block_root(), "id" => id);
|
||||
@@ -641,12 +645,14 @@ impl<T: BeaconChainTypes> BlockLookups<T> {
|
||||
} else {
|
||||
debug!(self.log, "Attempting to drop non-existent lookup"; "id" => id);
|
||||
}
|
||||
false
|
||||
}
|
||||
Err(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()]);
|
||||
self.drop_lookup_and_children(id);
|
||||
self.update_metrics();
|
||||
false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user