Skip to content

Commit

Permalink
Small Readability Improvement in Networking Code (sigp#5098)
Browse files Browse the repository at this point in the history
  • Loading branch information
ethDreamer authored and danielramirezch committed Feb 14, 2024
1 parent 59d536a commit 8c066be
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 11 deletions.
3 changes: 1 addition & 2 deletions beacon_node/network/src/sync/block_lookups/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,11 +101,10 @@ pub trait RequestState<L: Lookup, T: BeaconChainTypes> {
fn build_request_and_send(
&mut self,
id: Id,
already_downloaded: bool,
cx: &SyncNetworkContext<T>,
) -> Result<(), LookupRequestError> {
// Check if request is necessary.
if already_downloaded || !matches!(self.get_state().state, State::AwaitingDownload) {
if !matches!(self.get_state().state, State::AwaitingDownload) {
return Ok(());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,19 +114,18 @@ impl<L: Lookup, T: BeaconChainTypes> SingleBlockLookup<L, T> {
&mut self,
cx: &SyncNetworkContext<T>,
) -> Result<(), LookupRequestError> {
let block_root = self.block_root();
let block_already_downloaded = self.block_already_downloaded();
let blobs_already_downloaded = self.blobs_already_downloaded();

if block_already_downloaded && blobs_already_downloaded {
trace!(cx.log, "Lookup request already completed"; "block_root"=> ?block_root);
return Ok(());
if !block_already_downloaded {
self.block_request_state
.build_request_and_send(self.id, cx)?;
}
if !blobs_already_downloaded {
self.blob_request_state
.build_request_and_send(self.id, cx)?;
}
let id = self.id;
self.block_request_state
.build_request_and_send(id, block_already_downloaded, cx)?;
self.blob_request_state
.build_request_and_send(id, blobs_already_downloaded, cx)
Ok(())
}

/// Returns a `CachedChild`, which is a wrapper around a `RpcBlock` that is either:
Expand Down

0 comments on commit 8c066be

Please sign in to comment.