cargo fmt

This commit is contained in:
realbigsean
2023-08-24 14:35:06 -04:00
parent f90b190d9a
commit 42b34dbbe4
10 changed files with 55 additions and 49 deletions

View File

@@ -149,12 +149,14 @@ pub trait RequestState<L: Lookup, T: BeaconChainTypes> {
.copied()
.map(PeerShouldHave::BlockAndBlobs);
let Some(peer_id) = available_peer_opt.or_else(||request_state
.potential_peers
.iter()
.choose(&mut rand::thread_rng())
.copied()
.map(PeerShouldHave::Neither)) else {
let Some(peer_id) = available_peer_opt.or_else(|| {
request_state
.potential_peers
.iter()
.choose(&mut rand::thread_rng())
.copied()
.map(PeerShouldHave::Neither)
}) else {
return Err(LookupRequestError::NoPeers);
};
request_state.used_peers.insert(peer_id.to_peer_id());

View File

@@ -597,7 +597,7 @@ impl<T: BeaconChainTypes> BlockLookups<T> {
if response.is_some() {
debug!(self.log, "Response for a parent lookup request that was not found"; "peer_id" => %peer_id);
}
return
return;
};
match self.parent_lookup_response_inner::<R>(
@@ -781,7 +781,7 @@ impl<T: BeaconChainTypes> BlockLookups<T> {
"peer_id" => %peer_id,
"error" => msg
);
return
return;
};
R::request_state_mut(&mut parent_lookup.current_parent_request)
.register_failure_downloading();
@@ -845,14 +845,14 @@ impl<T: BeaconChainTypes> BlockLookups<T> {
cx: &mut SyncNetworkContext<T>,
) {
let Some(mut lookup) = self.single_block_lookups.remove(&target_id) else {
return;
};
return;
};
let root = lookup.block_root();
let request_state = R::request_state_mut(&mut lookup);
let Ok(peer_id) = request_state.get_state().processing_peer() else {
return
let Ok(peer_id) = request_state.get_state().processing_peer() else {
return;
};
debug!(
self.log,
@@ -1044,7 +1044,7 @@ impl<T: BeaconChainTypes> BlockLookups<T> {
.find(|(_, lookup)| lookup.chain_hash() == chain_hash)
.map(|(index, _)| index);
let Some(mut parent_lookup) = index.map(|index|self.parent_lookups.remove(index)) else {
let Some(mut parent_lookup) = index.map(|index| self.parent_lookups.remove(index)) else {
return debug!(self.log, "Process response for a parent lookup request that was not found"; "chain_hash" => %chain_hash);
};
@@ -1187,7 +1187,7 @@ impl<T: BeaconChainTypes> BlockLookups<T> {
.iter()
.find_map(|(id, lookup)| (lookup.block_root() == chain_hash).then_some(*id))
{
let Some(child_lookup) = self.single_block_lookups.get_mut(&child_lookup_id) else {
let Some(child_lookup) = self.single_block_lookups.get_mut(&child_lookup_id) else {
debug!(self.log, "Missing child for parent lookup request"; "child_root" => ?chain_hash);
return blocks;
};
@@ -1233,9 +1233,8 @@ impl<T: BeaconChainTypes> BlockLookups<T> {
mut parent_lookup: ParentLookup<T>,
) {
// We should always have a block peer.
let Ok(block_peer_id) =
parent_lookup.block_processing_peer() else {
return
let Ok(block_peer_id) = parent_lookup.block_processing_peer() else {
return;
};
let block_peer_id = block_peer_id.to_peer_id();
@@ -1301,15 +1300,13 @@ impl<T: BeaconChainTypes> BlockLookups<T> {
let Some(id) = self
.single_block_lookups
.iter()
.find_map(|(id, req)|
(req.block_root() == chain_hash).then_some(*id)) else {
.find_map(|(id, req)| (req.block_root() == chain_hash).then_some(*id))
else {
warn!(self.log, "No id found for single block lookup"; "chain_hash" => %chain_hash);
return;
};
let Some(lookup) = self
.single_block_lookups
.get_mut(&id) else {
let Some(lookup) = self.single_block_lookups.get_mut(&id) else {
warn!(self.log, "No id found for single block lookup"; "chain_hash" => %chain_hash);
return;
};

View File

@@ -135,8 +135,8 @@ impl<L: Lookup, T: BeaconChainTypes> SingleBlockLookup<L, T> {
/// 4. `Err`: The child is required, but has failed consistency checks.
pub fn get_cached_child_block(&self) -> CachedChild<T::EthSpec> {
if let Some(components) = self.cached_child_components.as_ref() {
let Some(block) = components.downloaded_block.as_ref()else {
return CachedChild::DownloadIncomplete
let Some(block) = components.downloaded_block.as_ref() else {
return CachedChild::DownloadIncomplete;
};
if !self.missing_blob_ids().is_empty() {

View File

@@ -57,8 +57,8 @@ impl<T: EthSpec> BlocksAndBlobsRequestInfo<T> {
for blob in blob_list {
let blob_index = blob.index as usize;
let Some(blob_opt) = blobs_buffer.get_mut(blob_index) else {
return Err("Invalid blob index");
};
return Err("Invalid blob index");
};
if blob_opt.is_some() {
return Err("Repeat blob index");
} else {